There's more than one way to do things | |
PerlMonks |
Re^3: Match all Non-0 and Lettersby AnomalousMonk (Archbishop) |
on Jun 25, 2017 at 00:16 UTC ( [id://1193466]=note: print w/replies, xml ) | Need Help?? |
The word ... will always be 8 continuous digits (or letters if there's corruption) not separated by whitespace. Note that if $Disc can ever possibly be longer than eight characters (update: with extra characters at the beginning), that regex will fail: If the string can only possibly be exactly eight characters, the $ end-of-string anchor is redundant. OTOH, I would tend to play it safe and include both start-of-string ^ and end-of-string anchors: it can't hurt, and may save you someday when one of your upstream assumptions fails you. The other thing I notice about the /(0{7})(\d$)/ regex is that (0{7}) captures a substring that can't possibly be anything other than '0000000', so why bother? (I assume you have some reason for capturing the trailing digit.) So what I might end up with would be something like m{ \A 0{7} (\d) \z }xms (in a testing matrix): (See also Test::More for more thorough testing possibilities.) Give a man a fish: <%-{-{-{-<
In Section
Seekers of Perl Wisdom
|
|