[Mastering-perl] Ch. Advanced regular expressions
Florian Merges
fmerges at cpan.org
Mon Dec 18 09:56:47 EST 2006
Hi,
Ch. Advanced regular expressions
=========================
Section: (?imsx-imsx:PATTERN)
-----------------------------------------------
I modify that snippet to use the /i flag to turn on case-insensitivity:
my $regex = qr/(\S+) hacker/; # ====> Where is the /i flag?
print "$regex\n";
The output now shows me that case-insensitivity is on, but the other flags
are off.
(?i-xsm:(\S+) hacker)
Section: Lookahead assertions, (?!PATTERN) and (?=PATTERN)
----------------------------------------------------------
I use a string with five 's followed by a b. ====> I use a string with
five a's followed by a b.
I think this section can be explained in a better way... it's a lil' bit
confusing. same than the next one.
Section: Lookbehind assertions, (? and (?<=PATTERN) ====> (?<!
PATTERN) and (?<= PATTERN)
---------------------------------------------------
number of os in fooo: ====> o's
Last example, is it correct the operation it does?
Section: Global matching
-------------------------------------
my $line = "Just another regex hacker, Perl hacker, and that's it!\n";
while( 1 )
{
my( $found, $type )= do {
if( $line =~ /\G([a-z]+(?:'[ts])?)/igc )
{ ( $1, "a word" ) } # ====> s/a
word/word/
Regards,
Florian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://five.pairlist.net/pipermail/mastering-perl/attachments/20061218/d251f52e/attachment.html
More information about the Mastering-perl
mailing list