I want a regex that will generate a match when it encounters “integer xyz” but only returns ‘xyz’ as the matching text. ‘xyz’ can be an identifier (letters+digits+underscore).
xyz by itself generates no match, only xyz preceded by ‘integer ‘
thanks!
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.
What language? In Perl 5.10 or PHP 5, I’d use
\K:For most other languages I’d suggest a lookbehind:
If it’s JavaScript, I’d recommend becoming a reader of Steve Levithan’s blog. Come to think of it, I’d recommend that in any case. 🙂
Of course, that’s assuming the regex must match only the variable name. Otherwise I’d go with the other responders’ recommendation of using a capturing group.