开发者

Struts2 validation expression sample

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜