i want to create a regex to match any lower case words but exclude 'return' and 'while', is it possible to do this? i don't want to solve like this:
return {/*nothing*/}
while {/*nothin开发者_如何学编程g*/}
[a-z]+ {/*some code*/}
I'm not 100% clear on what you want, but this might be helpful:
\b(?!(?:return|while)\b)[a-z]+
It matches
\b # A word break.
(?!(?:return|while)\b) # This is a negative look around
# saying don't match if a return
# or while is matched followed by
# a word break.
[a-z]+ # Match 1 or more lowercase letters.
精彩评论