开发者

Struts2 validation expression sample

开发者 https://www.devze.com 2023-01-26 09:13 出处:网络
What does this [D][C][M])[-]*[a-zA-z0-9]*$开发者_开发知识库 mean? What do *,^,$ [-] all mean? Please explain.That looks like part of a regular expression validator -

What does this [D][C][M])[-]*[a-zA-z0-9]*$开发者_开发知识库 mean? What do *,^,$ [-] all mean? Please explain.


That looks like part of a regular expression validator -

  • * - match the previous item 0 or more times
  • ^ - the beginning of a line
  • $ - the end of a line
  • [-] - the character class that contains "-"
  • [1-5] - the character class that contains the range of "1" to "5" inclusive
  • [a-z] - the character class that contains the range of "a" to "z" inclusive

[D][C][M])[-]*[a-zA-Z0-9]*$:

  • [D][C][M]) - some capture group ending with the characters "DCM"
  • [-]* - 0 or more "-"s
  • [a-zA-Z0-9]*$ - 0 or more alphanumeric characters at the end of the line
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号