Open jrgns opened 9 years ago
+1 - this feature would make many things easier
+1 - just ran into this myself while trying to 'patch' some multi-line inputs.
there's no way to set regexp modifiers
You can do this in-line in your regexp:
filter {
mutate {
gsub => [ "myfield", "(?m)dot '.' will now match the line terminator", "whatever" ]
}
}
The (?m)
flag will set multiline (m) flag for the whole regexp. I'm sorry we don't document this :(
You can learn more, for now, here: http://www.geocities.jp/kosako3/oniguruma/doc/RE.txt
An excerpt from the above link:
7. Extended groups
...
(?imx-imx) option on/off
i: ignore case
m: multi-line (dot(.) match newline)
x: extended form
(?imx-imx:subexp) option on/off for subexp
Hope this helps :)
Thanks, that helps! I had checked the standard JRuby Regexp.new() constructor args and it looked like a separate parameter was required not realizing that gsub() doesn't use the standard Ruby libraries.
So I guess this ticket needs to be changed to note that all that needs to change is the documentation...
does anyone have a copy of the link that @jordansissel provided? It appears to be dead now.
Long time since the last commet, but if some one is still looking for the link to oniguruma regex.
Since the needle / pattern of the gsub mutation can only be a string, there's no way to set regexp modifiers like case insensitive and multiline on the regular expression. This limits the usability of the mutation.
This can be done in one of two ways:
gsub_modifiers
option that will be applied to all the regular expressionsOption 1:
Option 2: