In rails cucumber there is this regex
When /^(?:|I )go to (.+)$/ do |page_name|
I know ?:
is a non-capturing group but what does it mean when it is there as an alternative separated by |
?
This isn't a special group, it just means "match nothing or I
": http://www.rubular.com/r/H3iJFLXaab
This should be the same as writing (?:I )?
(or to be more precise, (?:I )??
- because the empty string has precedence over I
, see also Is the lazy version of the 'optional' quantifier ('??') ever useful in a regular expression? )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With