in reply to Extracting substrings

/(Foo(.*)Bar)+?/g
That would work with POSIX regular expression semantics, but Perl regexen have different greediness semantics. Luckily, Perl 5.10.0 has a replaceable regex engine, so if you just wait till the module re::engine::TRE is fixed, you'll be able to use that regex (though you'll need a /x flag too).

Replies are listed 'Best First'.
Re^2: Extracting substrings
by ambrus (Abbot) on Feb 18, 2008 at 15:18 UTC

    It does work that way indeed:

    perl -wE 'use re::engine::TRE; print "<<$_>>\n" for "WhateverFooBlahBa +rMoreFooStuffBarMore" =~ /(?:Foo(.*)Bar)+?/gx'

    Output:

    <<Blah>> <<Stuff>>