Reputation:
Im trying to find using visual studio regex to find any line which contains at least 1 plus sign and the word enum one or more times.
To be clear: if it contains anywhere a plus sign and the sequence of letters "enum" with anything before, after and in between, it should return it.
Have tried many variations but no success:
\benum.+(?!\w)
Upvotes: 0
Views: 153
Reputation: 44316
^(?=.*enum)(?=.*\+).*$
Make sure you use multiline mode if your input string spans multiple lines.
Matches:
enum+
+enum
foobar+enum+barfoo
enumeration +
enumenum+
Does not match:
enum
+1
en+um
Explanation:
(?=.*enum)
- Checks that the line contains "enum"(?=.*\+)
- Checks that the line contains a "+".*
- Matches the entire text of the line^
and $
- Makes sure the entire line is matchedUpvotes: 5