In a regular expression in Ruby you can name a capture using the syntax:
/(?<name>…)/
and you can toggle the m/i/x options on/off within a non-capturing group using the syntax:
/(?i:[a-z])/
Is there any way to combine the two in a single group?
All of these work, but I am wondering if there is a simpler option:
/(?i:(?<name>…))/ # case-insensitive just within the region
/(?<name>(?i:…))/ # case-insensitive just within the region
/(?i)(?<name>…)(?-i)/ # case-insensitive turned on, then turned off
you can do that too:
/(?<name>(?i)...)/
AFIK, that's all!
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