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: Regular Expressions:
need some help

 



pyojeok
Deleted

Jan 22, 2001, 9:32 AM

Post #1 of 2 (1074 views)
need some help Can't Post

Can someone explain to me what does this expression does? I think it checks for digits and maybe characters but I am not sure. Thanks.

($argument =~ /^[sS][cC][\d+][\w*]/)



japhy
Enthusiast / Moderator

Jan 22, 2001, 10:12 AM

Post #2 of 2 (1071 views)
Re: need some help [In reply to] Can't Post

I think the author didn't know what they were doing...


Code
m{ 
^ # beginning of string
[sS] # an 's' or 'S'
[cC] # a 'c' or 'C'
[\d+] # a digit (0-9) or '+'
[\w*] # a word char (a-z, A-Z, 0-9, _) or '*'
}x

I suspect it was meant to be:


Code
$string =~ /^sc\d+\w*/i;

The /i modifier there allows case-insensitive matching, meaning the 's' can match either an 's' or an 'S'.

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

 
 


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

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