Everyone.
I think I’m missing something in ruby regex.
It seems that I cannot use %r/match code/s because Ruby has only /m, wich is not allows me to search my match line ignoring new line symbols.
What I need for now:
line 1 : a b c
line 2 : a b
line 3 : c
line 4 : a
line 5 : b c
I need to find here three matches
1. a b c
2. a b (new line) c
3. a ( new line ) b c
This can be done by using /s flag, but /s flag is used for encoding in Ruby, and /m flag just gives me this one match with all text
a b c
a b ( new line ) c
a ( new line ) b c
when I search expression like this %r/a.*c/m
I will appreciate for any information.
Ruby is using
mto enable the dotall mode, see regular-expressions.info. So your expression is exactly doing what you want thesmodifier for.Your problem is a different one, your regex is matching too greedy. So you should change it to
so the
.*?will only match to the next “c” and not to the last.