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:
COuld you kindly explain the meaning of REGEXP

 



per'l'over
Novice

Aug 29, 2008, 12:07 AM

Post #1 of 2 (3396 views)
COuld you kindly explain the meaning of REGEXP Can't Post

~ m/(always\s*\@(?:(?:(?!\n\n).)*)\n\n)/sig)

what does the above REGEXP do and explain it please


shawnhcorey
Enthusiast


Sep 17, 2008, 12:39 PM

Post #2 of 2 (3191 views)
Re: [per'l'over] COuld you kindly explain the meaning of REGEXP [In reply to] Can't Post


In Reply To
~ m/(always\s*\@(?:(?:(?!\n\n).)*)\n\n)/sig)

what does the above REGEXP do and explain it please


Adding whitespace to make it more readable:

m/ ( always \s* \@ (?: (?: (?! \n \n ) . )* ) \n \n ) /sigx

m/ == start match
( == start capture group
always == match the string 'always'
\s* == match zero, one or more whitespace characters
\@ == match the character '@'
(?: == group but don't capture
(?: == group but don't capture
(?! == negative look-ahead but don't match
\n == match a LF character
\n == match a LF character
) == end group
. == match any character
)* == end group matching zero, one or more of the group
\n == match a LF character
\n == match a LF character
) == end capture group
/ == end match
s == allow '.' to match LF character too
i == ignore case
g == repeat match as often as possible
x == ignore whitespace in pattern


It says to match always, followed by whitespace, followed by '@', not followed by a single blank line but followed by: 1) some lines, followed by a blank line; or 2) two blank lines.

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".

 
 


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

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