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

Adding a ? after the .+ would work fine

I might be missing something but I don't think that will work as desired. It will return the first item between slashes which is %, not ISIN. I think split might be better here. Something like

my $str = '%/%/ISIN/US1252691001'; my @elems = split m{/}, $str; my $isin = $elems[2];

Cheers,

JohnGG

Update:

You need a more complex regex to do this without split using zero-width look-around assertions, an alternation of two look-behinds and a look-ahead with an alternation.

my @elems = $str =~ m{(?(?<=\A)|(?<=/))(.*?)(?=/|\z)}g;