0

I would want to capture all combinations of my pattern even if it is overlapped.

Sample text

pack my box 12345 pack my box 67890 blah blah far away another pack my box 99999 is present

Expected output

Match 1 - pack my box 12345 pack my
Match 2 - pack my box 67890 blah bl
Match 3 - pack my box 99999 is pres

Regex

/pack my box.{0,14}/

However, Match 2 is not outputted since it is overlapping with 1.

enter image description here

Obviously, this is an SSCCE version of a bigger problem.

bragboy
  • 34,892
  • 30
  • 114
  • 171

1 Answers1

-1

Found out the answer (referenced from the duplicate post)

(?=(pack my box.{0,14}))

enter image description here

bragboy
  • 34,892
  • 30
  • 114
  • 171