Page 1 of 1

RegEx using m, multi-line strings

Posted: 16.07.2022 10:50
by sorim
How can I aktivate the flag Multiline in Regex

For example I search for
(.){40,}
(.){120,}

I wanted to search for some characters in the first line and remaining characters of the next line.

https://regex.sorokin.engineer/en/lates ... sions.html
m, multi-line strings

I tried without luck:
(.){40,}/m
m)(.){40,}

Posted: 16.07.2022 11:07
by main Alexey
for this case, multiline modifier is not needed.
working regex:

.{4,}\n.{8,}

to set multiline modifier:

(?m)text_here

Posted: 18.07.2022 11:17
by marcellino
Thank you, this works great!

(?ms)BlockStart.{40,40}

It selects 40 bytes after BlockStart, anyway if new line or not

asgasgasgw fasfggasfgaag
BlockStart asgdfasggafsdgadsfg
aaaasfgaafdsgasfg
afbaadsf afdsgadsfg BlockEnd afsbgafsdgasfg
aaaaaafrgasfgaadsfgg

Posted: 18.07.2022 11:45
by main Alexey
Here the modifier 'm' is not needed either:
(?s)BlockStart.{40,40}

(?m) is needed when you use meta-chars ^ and $.