Say you have the string "abcdefghi".

The positions in the string are:

  a b c d e f g h i
 ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
 0 1 2 3 4 5 6 7 8 9

If you have the regular expression:

/(de)/

Then the match starts at position 3, moves forward two characters, and ends at position 5, where the next match, if any, will start.

If it stopped at position 4 then it would only match 1 character.

If you want to explore all the gory details of regular expressions then get the book _Mastering Regular Expression_ by Jeffrey E. F. Friedl:

http://www.oreilly.com/catalog/regex3/index.html



John
Hi, John

Took your advice and start to read 'Mastering regular expression' by Jeffrey E.F.Friedl,

Can you explain below further?

on page, 205

push(@fields, $+) while $text =~ m{
"([^\"\\]*(?:\\.[^\"\\]*)*)",? #standard quoted string(with possible comma) | ([^,]+),? #or up to next comman(with possible comma)
   |   ,
}gx;

I am not totally understanding how the first line is matching standard quoted string.

I understand   "      " in beginning and end and option ,? at the very end.

now why ---> [^\"\\]* , should read anything except \ and " and \\ ? why?

and then followed by pretty much samething(in grouping only option ?:) followed by \\ ?? and samething?

How is that suppose to match quoted string? such as  "hi, how are you",

Also, how does this work?

defined($1) ? $1 : $3; This ternary reads if $1 is true, then test to see if $1 is defined? IF $1 is not true, then $3 is defined?(or ??)


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to