^.*(?=.*[0-9]).*$
I saw this posted in someone’s code. Is this a valid regex? I know the ? is supposed to make the items before it optional like abc? makes c optional. But ? is at the start of a capturing bracket. What does that mean?
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.
?alone means : OPTIONALLY match what was before.However,
(? .. )is used for assertions…In your case,
(?=is a look-ahead assertion, meaning : match if ONLY (what’s in the brackets) follows.