What I really need to know is :
- What does
(?(mean ? - What does
?:mean ?
The regex I am trying to figure out is :
(notice the above mentioned symbols in the following regex)
(?(?=and )(and )|(blah))(?:[1][9]|[2][0])[0-9][0-9]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
(?(?=and )(and )|(blah))pattern is used like if-then-else like(?(expression)yes|no)i.e
andwould be matched ifandis there elseblahwould be matched(?:)is a non capturing group.So it would not be included in the group or be used as back-reference \1So,
would match
NOTE(it’s all about the groups)
The samething can be achievend with this regex
(and |blah)(?:[1][9]|[2][0])[0-9][0-9].The only thing in which these regex differ is the number of groups formed.
So my regex would form 1 group which would contain either
andorblahYour regex would form no groups.It will form a group only if it matches
blah..