Orchid Fairy (À¼»¨ÏÉ×Ó) wrote:
Hi,
Hello,
# perl -le '$_="aXXXb"; print "one word is $1" while(/(X*)/g);'
one word is
one word is XXX
one word is
one word is
what are the three empty values in the output?
The pattern X* can match zero characters.
$ perl -le'$_="aXXXb"; print "one word is \047$1\047 at position $-[0]"
while /(X*)/g'
one word is '' at position 0
one word is 'XXX' at position 1
one word is '' at position 4
one word is '' at position 5
Between the beginning of the string and the character 'a' is the first
match.
Between the last 'X' and the 'b' is the third match.
Between the 'b' and the end of the string is the fourth match.
John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity. -- Damian Conway
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/