Regex match multiline content

Hello all.

I’m trying to match this text format

first line


 third line

This pattern failed to match multiline content.


This pattern will include everything after first line


similar to this one


Any idea how to make first pattern works as expected?


I was just about to write:

“Hopefully Kem replies because he speaks fluent Klingon” :stuck_out_tongue:

You misspelled, “is a genus of the highest order.”

Er, genieus… gennious… geenyus?


I will take #3 (geenyus) for 300 :smiley:

[quote=378819:@Kem Tekinay] (?Umi-s)^[\\t\\x20]*(#\\d+)\\b[\\s\\S]+(?:\\R\\R|\\z) [/quote]
I would like to get some translation from Klingon to some algorithmic english ?

Wow, thank you Kem. Can you explain that?

I was trying this pattern ^\\s*(\\#\\d+)\\s*(?:[\\r\ ])[\\s\\S]+(?=\\#) but can’t match the last text (#003 ...)

My version looks for start of line, spaces/tabs, if any, then the “#” followed by numbers. It then matches everything until it either matches two consecutive EOL characters (\R) or the end of the document (\z). The key is to turn off Greedy with the (?U) switch. Otherwise, it will keep matching until the end of the document each time.

I didn’t know about \\R and \\z escape characters.

Thank you Kem, I understood now :slight_smile: