A
Ammar Ali
Hello,
This is definitely an edge case, but an interesting one. Suppose we
have a configuration string like "mux
ff mix
n" and we want to match
the "mix
n" (actually either) part passively (i.e. not captured).
=> 4
Oops, forgot about options. 100% understandable.
Several attempts to work around it
Wrap one of the option characters in a set
on|off))\b/
from /Users/ammar/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
Wrap all option characters in individual sets
SyntaxError: (irb):3: undefined group option: /\b(?[m][x]
on|off))\b/
from /Users/ammar/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
Wrap the option characters in a group
SyntaxError: (irb):4: undefined group option: /\b(?(mix)
on|off))\b/
from /Users/ammar/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
Move the anchors inside the passive group
on|off))\b)/
from /Users/ammar/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
If the passivity is dropped, it works as intended, of course.
=> 7
The same occurs with ruby 1.8, but with a slightly different error message:
undefined (?...) sequence:
I was hoping that one of the workarounds above would work, but now I'm
thinking this is might be a bug. I want to see what others think
before I cry wolf.
Regards,
Ammar
This is definitely an edge case, but an interesting one. Suppose we
have a configuration string like "mux
the "mix
=> 4
Oops, forgot about options. 100% understandable.
Several attempts to work around it
Wrap one of the option characters in a set
SyntaxError: (irb):2: undefined group option: /\b(?[m]ix"muxn mix
ff" =~ /\b(?[m]ix
on|off))\b/
from /Users/ammar/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
Wrap all option characters in individual sets
"muxn mix
ff" =~ /\b(?[m][x]
on|off))\b/
SyntaxError: (irb):3: undefined group option: /\b(?[m][x]
from /Users/ammar/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
Wrap the option characters in a group
SyntaxError: (irb):4: undefined group option: /\b(?(mix)
from /Users/ammar/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
Move the anchors inside the passive group
SyntaxError: (irb):5: undefined group option: /(?\b(([m]ix)"muxn mix
ff" =~ /(?\b(([m]ix)
on|off))\b)/
from /Users/ammar/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'
If the passivity is dropped, it works as intended, of course.
=> 7
The same occurs with ruby 1.8, but with a slightly different error message:
undefined (?...) sequence:
I was hoping that one of the workarounds above would work, but now I'm
thinking this is might be a bug. I want to see what others think
before I cry wolf.
Regards,
Ammar