0

I want to match string like 12af-23f4-123d-. Although it is possible to use [0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{4}\- Can I use nested format like [[0-9a-f]{4}\-]{3} ?

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Shan
  • 41
  • 1
  • 5

1 Answers1

0

Your original regex:

[0-9a-f]{4}\-[0-9a-f]{4}\-[0-9a-f]{4}\-

can be simplified in

([0-9a-f]{4}\-){3}

or

(([0-9a-f]{4}\-){3}) 

depending on the fact that you want to use the whole match as a whole or not (e.g. backreference,...).

Tested on regex101:

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

https://regex101.com/r/gLSu92/2

Allan
  • 12,117
  • 3
  • 27
  • 51