in reply to Re: Re: Strip user-defined words with regexp
in thread Strip user-defined words with regexp

Given the OP's examplei input

With the grep

$message = "\n +_ ABC1_\n2 3 4"; print join'|', ( grep $_, split /[^A-Za-z0-9]+/ , $message )[0,1]; ABC1|2

Without

$message = "\n +_ ABC1_\n2 3 4"; print join'|', split /[^A-Za-z0-9]+/ , $message; |ABC1|2|3|4

You'll notice the null leading element.

The list slice is pretty redundant, but it does make it obvious that you are only wanting the first two.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail