in reply to Re^3: extracting names between symbols
in thread extracting names between symbols
If you change the split regex to allow optional spaces around the hyphen and prepend and append hyphens to the text you can avoid the space trimming substitutions. You do have to shift away the empty first element though.
$ perl -le ' > $str = q{ this- is-aline - one- two }; > @arr = split m{\s*-\s*}, qq{-$str-}; > shift @arr; > print qq{->$_<-} for @arr;' ->this<- ->is<- ->aline<- ->one<- ->two<- $
I hope this is of interest.
Cheers,
JohnGG
|
|---|