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:
Help with string

 



BAbdulBaki
newbie

Sep 12, 2001, 9:27 AM

Post #1 of 3 (4985 views)
Help with string Can't Post

I need a string that matches the following criteria:
1. Any alphanumeric character from [A-Za-z] and [0-9].
2. Special characters like "." (period), "-" (dash), "(" (open para), ")" (close para), "," (comma), "?" (question mark), ":" (colon), "/" (slash).
3. The length of the string is not blank.
4. The length of the string is not greater than 69.
5. No two consecutive slashes are in the string.
6. Does not begin or end with a slash.
If anyone can create that in Perl and/or Schema that would be appreciated. Thanks.



mhx
Enthusiast

Sep 12, 2001, 11:51 AM

Post #2 of 3 (4981 views)
Re: Help with string [In reply to] Can't Post

You can use the following subroutine to check if a string matches your criteria:

Code
sub check_string 
{
my $str = shift;
$str =~ /^[A-Za-z0-9-:.,\/()?]{1,69}$/
and substr($str, 0, 1) ne '/'
and substr($str,-1, 1) ne '/'
and index($str, '//') < 0;
}

Hope this helps.

-- Marcus


Code
s$$ab21b8d15c3d97bd6317286d$;$"=547269736;split'i',join$,,map{chr(($*+= 
($">>=1)&1?-hex:hex)+0140)}/./g;$"=chr$";s;.;\u$&;for@_[0,2];print"@_,"



dsb
stranger

Apr 11, 2002, 7:23 PM

Post #3 of 3 (4927 views)
Re: [BAbdulBaki] Help with string [In reply to] Can't Post

Sounds like homework.

Try getting to know regular expressions a bit. There are plenty of online references and free tutorials with which to do this.

_______________________

dsb
PerlGuy

 
 


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

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