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: Re: [cybex] Syntax for string variances in Perl: Edit Log



FishMonger
Veteran / Moderator

Nov 30, 2013, 6:19 AM


Views: 46845
Re: [cybex] Syntax for string variances in Perl


Code
#!/usr/bin/perl 

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

my $regex = 'm/^|\s*\(?SUBJECT\)*\s*\d{0,2}\)*\s*:*\s*|\s{2}\(?S\)*\d{0,2}\)*\s*:*\s*|/';

print YAPE::Regex::Explain->new($regex)->explain();



Code
c:\test>explain-regex.pl 
The regular expression:

(?-imsx:m/^|\s*\(?SUBJECT\)*\s*\d{0,2}\)*\s*:*\s*|\s{2}\(?S\)*\d{0,2}\)*\s*:*\s*|/)

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):
----------------------------------------------------------------------
m/ 'm/'
----------------------------------------------------------------------
^ the beginning of the string
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
\(? '(' (optional (matching the most amount
possible))
----------------------------------------------------------------------
SUBJECT 'SUBJECT'
----------------------------------------------------------------------
\)* ')' (0 or more times (matching the most
amount possible))
----------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
\d{0,2} digits (0-9) (between 0 and 2 times
(matching the most amount possible))
----------------------------------------------------------------------
\)* ')' (0 or more times (matching the most
amount possible))
----------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
:* ':' (0 or more times (matching the most
amount possible))
----------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
\s{2} whitespace (\n, \r, \t, \f, and " ") (2
times)
----------------------------------------------------------------------
\(? '(' (optional (matching the most amount
possible))
----------------------------------------------------------------------
S 'S'
----------------------------------------------------------------------
\)* ')' (0 or more times (matching the most
amount possible))
----------------------------------------------------------------------
\d{0,2} digits (0-9) (between 0 and 2 times
(matching the most amount possible))
----------------------------------------------------------------------
\)* ')' (0 or more times (matching the most
amount possible))
----------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
:* ':' (0 or more times (matching the most
amount possible))
----------------------------------------------------------------------
\s* whitespace (\n, \r, \t, \f, and " ") (0 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
/ '/'
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------



(This post was edited by FishMonger on Nov 30, 2013, 6:20 AM)


Edit Log:
Post edited by FishMonger (Veteran) on Nov 30, 2013, 6:20 AM
Post edited by FishMonger (Veteran) on Nov 30, 2013, 6:20 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