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: [FYI] MSXML HTTP translates response status code 204 to 1223
    ... Don't you think regex is really a wrong tool for the job in this case? ... Modifying the property requires much less effort than modifying the method. ... the RegExp provides the user which much an ... Efficiency difference most definitely doesn't matter. ...
    (comp.lang.javascript)
  • Re: Reg Ex
    ... keywords like SanFrancisco and Francisco? ... Instead of modifying the regex, how about simply working on the data ...
    (comp.lang.ruby)