RegEx using m, multi-line strings

Post Reply
sorim
Posts: 5
Joined: 04.10.2020 09:54

RegEx using m, multi-line strings

Post 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,}
main Alexey
Posts: 2300
Joined: 25.08.2021 18:15

Post by main Alexey »

for this case, multiline modifier is not needed.
working regex:

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

to set multiline modifier:

(?m)text_here
marcellino
Posts: 2
Joined: 27.06.2022 09:07

Post 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
main Alexey
Posts: 2300
Joined: 25.08.2021 18:15

Post by main Alexey »

Here the modifier 'm' is not needed either:
(?s)BlockStart.{40,40}

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