Reputation: 10290
Using rubular.com as a guide, I am trying to get this expression to work correctly.
^((move|travel|fly) (.+) pixels)
Basically, this matches
move 5 pixels
fly 10 pixels
travel 3 pixels
The matches I get are:
move 5 pixels
move
5
The problem is that I don't want to return the matches for the options. Is there some way to match the regular expression but not return the match for those in that option? Ideally it would be:
move 5 pixels
5
Thanks in advanced!
Upvotes: 1
Views: 70
Reputation:
Use the ?:
option on the group to stop it from being stored and used as a backreference.
^((?:move|travel|fly) (.+) pixels)
Upvotes: 0
Reputation: 838256
Use a non-capturing group:
^((?:move|travel|fly) (.+) pixels)
See it working online: rubular
Upvotes: 2