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:
Regular expressions help

 



esiason14
New User

Sep 26, 2009, 5:57 PM

Post #1 of 2 (3288 views)
Regular expressions help Can't Post

This is from the "Learning Perl" book:

Here, we give you the answer; you decide what problem it's trying to solve. What do these real-world patterns match? What might they be used for?

/"([^"]*)"/
/^0?[0-3]?[0-7]{1,2}$/
/^\b[\w.]{1,12}\b$/

Can someone explain what these mean? Please


toolic
User

Sep 26, 2009, 6:13 PM

Post #2 of 2 (3286 views)
Re: [esiason14] Regular expressions help [In reply to] Can't Post

http://search.cpan.org/~pinyan/YAPE-Regex-Explain-3.011/Explain.pm can do a much better job than I can. For example:


Code
use strict;    
use warnings;
use YAPE::Regex::Explain;

my $re = '"([^"]*)"';
print YAPE::Regex::Explain->new($re)->explain;

__END__

The regular expression:

(?-imsx:"([^"]*)")

matches as follows:

NODE EXPLANATION
----------------------------------------------------------------------
(?-imsx: group, but do not capture (case-sensitive)
(with ^ and $ matching normally) (with . not
matching \n) (matching whitespace and #
normally):
----------------------------------------------------------------------
" '"'
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
[^"]* any character except: '"' (0 or more
times (matching the most amount
possible))
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
" '"'
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------


 
 


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

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