in reply to Regex Help
More than looking inefficient, it looks unnecessarily cluttered, which can contribute to bugs:
Making those changes would yield:
9818\D?9[01]\D?\d{2}(?:\D?\d{4}){2}
Now with the /x modifier, you can further clarify things like this:
m/ 9818 # A literal. \D? # Optional non-digit. [01] # Require a zero or a one. \D? # Another optional non-digit. \d{2} # Require two digits. (?: # Group but don't capture. \D? # Another optional non-digit. \d{4} # Followed by four digits. ){2} # Repeated twice. /x
As for efficiency, what problems are you encountering? If you're dealing with huge input you're probably IO bound anyway.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex Help
by gautamparimoo (Beadle) on Mar 25, 2013 at 08:48 UTC | |
by davido (Cardinal) on Mar 25, 2013 at 08:55 UTC | |
by gautamparimoo (Beadle) on Mar 25, 2013 at 09:29 UTC | |
by Anonymous Monk on Mar 25, 2013 at 10:17 UTC | |
by davido (Cardinal) on Mar 25, 2013 at 16:29 UTC | |
|