Joe_Cullity has asked for the wisdom of the Perl Monks concerning the following question:
Problem with pattern matching
Need in -if- statement that will detect when a 2 char string contains a non digit.( I’ve already checked the string's lenght so it's guaranteed to be 2 chars long.) In other words. The string can contain "00","01"."02"…"99" but NOT stuff like " 0". "0 ", "9A", "Z7"...
if ($my_dat =~ /^[0-9]/ ) {some code here;}
Works if the 1st char is not a digit ( catches stuff like " 0" and "A4" ) but misses stuff if 2nd char is not a digit ( Misses stuff like "0 " and "7W")
Can someone help ?
Code tags added by davido per consideration. See Writeup Formatting Tips for explanation.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Question on pattern matching
by Limbic~Region (Chancellor) on Jun 16, 2005 at 19:41 UTC | |
|
Re: Question on pattern matching
by Zaxo (Archbishop) on Jun 16, 2005 at 19:43 UTC | |
|
Re: Question on pattern matching
by ikegami (Patriarch) on Jun 16, 2005 at 19:40 UTC | |
by ikegami (Patriarch) on Jun 16, 2005 at 21:05 UTC | |
|
Re: Question on pattern matching
by Transient (Hermit) on Jun 16, 2005 at 19:42 UTC | |
by nobull (Friar) on Jun 16, 2005 at 20:42 UTC | |
|
Re: Question on pattern matching
by shady (Sexton) on Jun 16, 2005 at 22:00 UTC | |
|
Re: Question on pattern matching
by sh1tn (Priest) on Jun 16, 2005 at 22:06 UTC |