in reply to Re: Regular expression
in thread Regular expression

Thanks AnomalousMonk. Your update problem what very good. I could understand most part of the code but I don't understand what (?i) is used for in "($units =~ m{ (?i) kgs? }xms"

Replies are listed 'Best First'.
Re^3: Regular expression
by AnomalousMonk (Archbishop) on Oct 29, 2017 at 22:10 UTC
    ... what (?i) is used for ...

    This regex operator turns on case insensitivity until the end of the current matching scope. See  (?adlupimsx-imsx) and  (?^alupimsx) in Extended Patterns. It has the same effect (but with scope control) as the  /i global pattern modifier; see Modifiers. (Both in perlre.) Aside from its scope flexibility, I prefer to use  (?i) rather than the  /i modifier because of its greater general readability.


    Give a man a fish:  <%-{-{-{-<

      Thanks for this.