Reputation: 9
Guys I want to write regex that matches all those strings starting with lower or ground and end with flat.. i.e. both these two would be captured in their entirety.
Example:
LOWER GROUND FLAT
GROUND FLAT
However, this does not seem to be doing the job:
^LOWER|GROUND\sFLAT$
Upvotes: 0
Views: 93
Reputation: 785156
You should be using:
^(LOWER|GROUND)\s+.*?FLAT$
As you wrote it like
^LOWER|GROUND\sFLAT$
it is basically trying to match either
^LOWER
or
GROUND\sFLAT$
The parentheses change that to your original intent.
Upvotes: 3