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
  • 561,645
  • 34
  • 376
  • 476
Shan
  • 11
  • 1
  • 4

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
  • 11,650
  • 3
  • 27
  • 49