in reply to extract text between slashes

You said:
extract the data between slashes within a string of course

which might be more than one item.

my $str = '%/%/ISIN/US1252691001'; my @strings = $str =~ m{(?<=/)[^/]+}g ; print join ', ', @strings, "\n"; print $strings[1];

Regards

mwa

Replies are listed 'Best First'.
Re^2: extract text between slashes
by johngg (Canon) on Oct 31, 2007 at 19:36 UTC
    print join ', ', @strings, "\n";

    I'm not sure whether you intended a trailing ', ' in the output. If not, you could use parentheses

    print join(', ', @strings), "\n";

    I might instead tinker with the list separator

    print do { local $" = q{, }; qq{@strings\n}; };

    Cheers,

    JohnGG

      I'm not sure whether you intended a trailing ', ' in the output. If not, you could use parentheses

      .oO you got me ...

      If I'd say now "I didn't care if a trailing comma would show up" nobody would believe me. If I'd say "I tried to make the output of print "@strings\n"; more distinct for a beginner", the same would happen.

      Therefore the best would be to take the blame and admit failure ;-)

      Thanks & Regards

      mwa