Search code examples
regexperlrepeatsimplification

Perl Regular Expression simplification


I want to simplify the following statement.

if($_=~/^([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])/)

Is there an alternate way I can write the above statement without repeating [0-9a-fA-F] n times ?


Solution

  • Try this

    if($_=~/^([0-9a-fA-F]{5})/)