0

Regex: [0-9]{6-8}([0-9]{4})

Test Strings:

sfad 123456781234 afd sadfa fdads
sfd 12345671234 24312 fasdfa dsfafd
221 1234561234 safd safd23 34

Expected:

I need the end part 1234 captured in a group on each line.

Actual: No matches. :(

I would like to make [0-9]{6-8} to match the least possible characters so all these 3 strings would match. How do I make this lazy as it seems to be greedy now.

I need only regex solutions as this is part of a bigger solution. Here's a link to play with it: https://regex101.com/r/eF5pA9/1

San
  • 3,933
  • 7
  • 34
  • 43

1 Answers1

0

[0-9]{6,8}([0-9]{4}) with g modifier matches all three.

Thanks @anubhava and @Anderson Pimentel.

San
  • 3,933
  • 7
  • 34
  • 43