in reply to Re: extract text between slashes
in thread extract text between slashes

Also, keep in mind that he wants the contents of the *second* pair of slashes. Assuming that the first one with the percent sign is static, m{/\%/(.*?)/} might work. otherwise, he could grab all matches and filter out the wrong ones, or split the whole string beforehand:
# method 1 @matches = $string =~ m{/(.*?)/}g; # method 2 @matches = split m{/}, $string; # print the one you want print $matches[1];

__________
Systems development is like banging your head against a wall...
It's usually very painful, but if you're persistent, you'll get through it.

Replies are listed 'Best First'.
Re^3: extract text between slashes
by johngg (Canon) on Oct 31, 2007 at 19:50 UTC
    Unfortunately, your method 1 isn't going to do the trick because the regex is going to consume %/%/ when doing the first match and the next attempted match is left with ISIN/US1252691001 to work with so the match fails.

    $ perl -le ' > $string = q{%/%/ISIN/US1252691001}; > @matches = $string =~ m{/(.*?)/}g; > print for @matches;' % $

    Cheers,

    JohnGG