0

For example, I suggest I have these code blocks

(...) 38:f8:b7:90:45:92 (...)
(...) 3c:83:b5:65:85:ba (...)
(...) 08:00:8c:1a:3d:d9 (...)
(...) 00:18:f5:63:84:7c (...)

I selected these code blocks like this.

([A-Z0-9a-z]{2}:){5}[A-Z0-9a-z]{2}

But repetition of [A-Z0-9a-z]{2} is somewhat tedious. Is there any way to reduce above regex?

JongHyeon Yeo
  • 879
  • 1
  • 10
  • 18
  • 1
    What is your regex flavor? – Wiktor Stribiżew Jul 14 '18 at 10:08
  • If you are matching but not validating you could use `\w\w(?::\w\w){5}`. See live demo here https://regex101.com/r/pBtCQV/1 – revo Jul 14 '18 at 10:10
  • Otherwise if you are using a Perl compatible regex flavor you may want to give [`(?i)([a-z\d]{2})(?:(?1)){5}`](https://regex101.com/r/Jgngzv/1) a try. – revo Jul 14 '18 at 10:15
  • It is probably a dupe of any of these: https://stackoverflow.com/questions/8204214/regex-reusing-subexpressions, http://stackoverflow.com/questions/19794603/reuse-part-of-a-regex-pattern, https://stackoverflow.com/questions/46466549/regex-reuse-a-pattern-to-capture-multiple-groups, and there are lot of others. – Wiktor Stribiżew Jul 14 '18 at 10:25

0 Answers0