in reply to Re: Why does split on /./ not split the string?
in thread Why does split on /./ not split the string?

split returns only the string segments between, but not including the matching chars.
<nit>

Uhm, then what does this do?

my @list = split /([\W]+)/, 'one;two--three!!!';
Updated: Corrected '+' typo.

</nit>

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^3: Why does split on /./ not split the string?
by parv (Parson) on Dec 08, 2005 at 01:02 UTC

    Your pattern to split has capturing parentheses, which returns fields along w/ the delimiters; see perldoc -f split. Also, that [+] (mind you + here is just a plain plus sign) is useless as the string to be split lacks one.

    Try this ...

      I was trying to nitpick, but failed somewhat. The point is that split's behavior (wrt/ the OP) depends on the presence of capturing parens and the DWIMmery of split.

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of