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:
Valid Regular expression

 



anilm
stranger

Jun 29, 2001, 7:14 AM

Post #1 of 2 (3335 views)
Valid Regular expression Can't Post

Dear friends!
how do i find out the validity of a regular expression pattern, with out passing any string. (I mean are the characters, special characters etc.. used in the pattern are proper.)

regards
anilm



mhx
Enthusiast

Jun 29, 2001, 7:54 AM

Post #2 of 2 (3334 views)
Re: Valid Regular expression [In reply to] Can't Post

Hi,

say your regex is stored in $re, then you can test if it's valid with

Code
eval { '' =~ /$re/ }; 
unless( $@ ) {
print "Regex is valid!\n";
}
else {
print "Regex is invalid!$@";
}

Hope this is what you were looking for.

-- Marcus

(This post was edited by mhx on Jun 29, 2001, 6:59 AM)

 
 


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

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