0

Given something like this - where the string contains line breaks and carriage returns; I added the character in to the example for brevity:

AB01 88 99 10
\nHH01 123 123
\nHH02 123 123
\nHH03 123 123
\nXX10 88 99 10
\nHH01 456 789
\nHH02 456 789
\nHH03 456 789
\nXX10 99 10 11

I am trying to extract groups of HH01 to HH03

I'm expecting a result like this.

groups = [
        "HH01 123 123\nHH02 123 123\nHH03 123 123",
        "HH01 456 789\nHH02 456 789\nHH03 456 789"
         ]

I'm trying to extract it with regular expressions, though am not fully understanding what I'm doing.

My expression looks like this: /HH01(.*)HH03/

I can't figure out how to handle the line breaks. I've tried /HH01(.*)HH03/m too.

Can anybody help point me in the right direction?

Darren Wainwright
  • 28,457
  • 19
  • 68
  • 116

0 Answers0