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: Intermediate:
REG Exp

 



arunanirudhan
Novice

Mar 28, 2011, 3:49 AM

Post #1 of 6 (1536 views)
REG Exp Can't Post

Please tell me the meaning of first ? in this exp
(?:\w+:\w+@)?
Arun Anirudhan
MTech Student, NIT Calicut


rovf
Veteran

Mar 28, 2011, 8:46 AM

Post #2 of 6 (1531 views)
Re: [arunanirudhan] REG Exp [In reply to] Can't Post

(?:....)

Non-capturing group.

It's like (.....), but does not set the $-variables ($1,$2,...).

See perldoc perlre.


arunanirudhan
Novice

Mar 28, 2011, 7:51 PM

Post #3 of 6 (1522 views)
Re: [rovf] REG Exp [In reply to] Can't Post

Thank you for the reply...
This is the complete line
/(?#Username:Password) (?:\w+:\w+@)?/
Can you please explain this?
Arun Anirudhan
MTech Student, NIT Calicut


FishMonger
Veteran / Moderator

Mar 28, 2011, 8:09 PM

Post #4 of 6 (1520 views)
Re: [arunanirudhan] REG Exp [In reply to] Can't Post


Code
#!/usr/bin/perl 

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

my $REx = '/(?#Username:Password) (?:\w+:\w+@)?/ ';

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


Outputs:

Code
D:\perl>test.pl 
The regular expression:

(?-imsx:/(?#Username:Password) (?:\w+:\w+@)?/ )

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, but do not capture (optional
(matching the most amount possible)):
----------------------------------------------------------------------
\w+ word characters (a-z, A-Z, 0-9, _) (1 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
: ':'
----------------------------------------------------------------------
\w+ word characters (a-z, A-Z, 0-9, _) (1 or
more times (matching the most amount
possible))
----------------------------------------------------------------------
@ '@'
----------------------------------------------------------------------
)? end of grouping
----------------------------------------------------------------------
/ '/ '
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------



miller
User

Mar 28, 2011, 10:44 PM

Post #5 of 6 (1518 views)
Re: [arunanirudhan] REG Exp [In reply to] Can't Post


In Reply To
Thank you for the reply...
This is the complete line
/(?#Username:Password) (?:\w+:\w+@)?/
Can you please explain this?


(?#Username:Password) is a comment

Just look at http://perldoc.perl.org/perlre.html for details of groups like that or do like Fishmonger demonstrated.

- Miller


arunanirudhan
Novice

Mar 29, 2011, 1:20 AM

Post #6 of 6 (1517 views)
Re: [FishMonger] REG Exp [In reply to] Can't Post

Thank you very much
Arun Anirudhan
MTech Student, NIT Calicut

 
 


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

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