CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Validiating variable Content....

 



yotam_k
Deleted

Jan 26, 2001, 8:39 AM

Post #1 of 4 (1192 views)
Validiating variable Content.... Can't Post

Could someone tell me how to check if a string "$string" contains :
a. numbers
b. charcters like : "|" , "+"

Thank you very much !
yotam.



japhy
Enthusiast / Moderator

Jan 26, 2001, 10:58 AM

Post #2 of 4 (1189 views)
Re: Validiating variable Content.... [In reply to] Can't Post

You probably want a regular expression:


Code
if ($string =~ /[0-9|+]/) { 
# $string contains a digit or a | or a +
}

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author


yotam_k
Deleted

Jan 27, 2001, 2:44 AM

Post #3 of 4 (1183 views)
Re: Validiating variable Content.... [In reply to] Can't Post

So if I want to validiate If string is only "|" sign I Write Like This :
if ($string =~ /[|]/) {
# $string contains only |
}
?

Yotam.



modified
Deleted

Jan 27, 2001, 7:18 AM

Post #4 of 4 (1182 views)
Re: Validiating variable Content.... [In reply to] Can't Post

No, that would just check to see if $mystring contains a |, not neccessarily only a |. I think removing the brackets ([]) will check to see if it contains only a |.


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives