Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Match all Non-0 and Lettersby Laurent_R (Canon) |
on Jun 24, 2017 at 09:11 UTC ( [id://1193439]=note: print w/replies, xml ) | Need Help?? |
Hi arblargan,
as other monks have already mentioned, all you really need is a single regex such as /0{7}\d/ (or perhaps /^0{7}\d$/ if the word you get is just the number). You could, however, split your word into two parts as you did, but you made a logical error: you should have a "or", not an "and" in your condition for detecting a corrupt word, because you want to detect if the first part is not made of 0 OR if the second part is not a digit. So, you might fix your code as follows: But, again, this was just to explain the error in your code, the solution with /0{7}\d/ is much simpler and better. Update: this was intended to show the logical error ("and" instead of "or"). As pointed out by AnomalousMonk just below, the regexes are also wrong in terms of the intended purpose described in the original post.
In Section
Seekers of Perl Wisdom
|
|