in reply to Re: splitting
in thread splitting

The only tricky thing about the regexes supplied by the other two (besides the use of parenthesis, which is new to me and very cool) is that they specify that there is at least one whitespace character immediately before and after the delimiter. Using an asterisk would make that optional.

Does that explain it?

Replies are listed 'Best First'.
RE: RE: Re: splitting
by perlmonkey (Hermit) on Apr 28, 2000 at 01:49 UTC
    The only reason I put the \s in the regex above was because the original posting wanted: (text,delimeter,text,delimeter,text) with the white space removed ... so my regex does not capture the white space. Perhaps I was not that clear: do what ever you want with the regex, but note that whatever is in the '()' will be returned into the array. So I just as well could have done:@array = split(/(delimeter)/, $str); But then @array would have the white space in some of the array elements:
    @array would be ("text ", "delimeter', " text ", "delimeter", " text") +;
    Hopefully this will clear some things up.