|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I need to check for the existence of a specific string at the beginning of a variable and based upone its existence/absence perform a conditional branch. The line I am attepting to use is as follows -
if ($zip =~ /^191*/) testing for the characters 191 at the beginning of the $zip variable. Is this code correct or am I having a major brain fart here? Any feedback is mucho appreciated. K |
|
#2
|
|||
|
|||
|
this code is correct, kinda...
if you are testing for the character * you need to escape it by doing * . but if you are using it to say zero or more characters after the 191, then you can either use .* or nothing... it should work the same. |
|
#3
|
|||
|
|||
|
All you have to do is:
if ($zip =~ /^191/) { # true } else { # false } [Update] I also just realized that your pattern is wrong because all numbers starting with "19" would be flagged as OK. Try my solution above. [This message has been edited by Anonym0us (edited December 16, 2000).] |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Help - String manipulation/Conditons |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|