in reply to Str extract the word between the first and the 2nd '|' character

To expand on Anonymonk's reference to split and incorporating your whitespace modification to FunkyMonk's solution.

my $secondWord = ( split m{\s*\|\s*}, $string )[1];

Six of one, half a dozen of the other, really!

Cheers,

JohnGG

  • Comment on Re: Str extract the word between the first and the 2nd '|' character
  • Download Code

Replies are listed 'Best First'.
Re^2: Str extract the word between the first and the 2nd '|' character
by dani_cv (Acolyte) on Apr 11, 2008 at 14:51 UTC
    Thank you!