Reputation: 90776
I'm trying to match this kind of strings with a regular expression:
{{location|
{{location dec|
{{location other|
so I came up with this regular expression:
{{location( dec| other|)
which works fine, however it's creating a group at ( dec|)
, which I don't need. Is there any way to do the same thing but without creating a group?
Upvotes: 1
Views: 81
Reputation: 425033
You need a group, but you can make it a non-capturing group by adding ?:
after the opening bracket:
(?: dec| other|)
Non-capturing means the group exists just for the expression; no back references are possible and group numbering is unaffected.
Upvotes: 4
Reputation: 7779
You can use ?:
to prevent group creation so please give a try to:
{{location(?: dec| other|)
Upvotes: 2