-1

I have a string which goes like this.

010002 D324Y56HY INTEREST 

010002 SAD21 INTEREST

I am trying to create two groups here with the regex (010002)[\s\S]\*INTEREST

But the regex matches last occurrence of INTEREST. I need it to stop the matching at the first occurrence and create another group with the next occurrences. Can someone guide me please?

Please find the link below.

https://regex101.com/r/tXfBGf/1/

Zeitounator
  • 38,476
  • 7
  • 53
  • 66

1 Answers1

2

Try this:

/(010002)[\s\S]*?INTEREST/

(add question mark for shortest match)

Anatoliy R
  • 1,749
  • 2
  • 14
  • 20