Issue
I'm trying to figure out a regex to express this string:
dev_XXX_<name>
where XXX is a 3 digit number and name is already expressed with /[0-9a-zA-Z \- _]/
.
This regular expression will be used as a model validation rule in PHP/YII, so it's a PCRE regular expression.
My non-working solution is this one:
/^dev_([0-9]{3})_<([0-9a-zA-Z \- _])>*$/
But it seems to not accept the last major sign.
Thank you for any help & explanations!
Solution
Looks like your asterisk is in the wrong place
/^dev_([0-9]{3})_<([0-9a-zA-Z \- _])>*$/
should be
/^dev_([0-9]{3})_<([0-9a-zA-Z \- _]*)>$/
This will mean that your character set [0-9a-zA-Z \- _]
should match zero or more of those characters
Answered By - Pudge601
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.