Re: the only difference is the 'x' after '/g'




Tom Arnall wrote:
the following code:

my (@main);
$_="
From a
From: b
From: c
From: d
";
@main = /From [^\n]*?\n.*?(From: .*?\n).*?/gx;
print "@main";
print "------------------------------\n";
@main = /From [^\n]*?\n.*?(From: .*?\n).*?/g;
print "@main";

produces:

From: b
From: d
------------------------------
From: b

the only difference between the two regex lines is the 'x' after '/g' in the
first of the two regex lines.

those crazy modifiers -- always modifying something!

but I digress. Question, please?

-jp

.



Relevant Pages

  • disappointing .*?
    ... presence/absence of '.*?'. ... The regex in Line 6 seems to be using the ... Tom Arnall ... north spit, ca ...
    (perl.beginners)
  • Re: Reg Ex
    ... keywords like SanFrancisco and Francisco? ... Instead of modifying the regex, how about simply working on the data ...
    (comp.lang.ruby)