Thursday, March 31, 2011

single String.split() call for splitting both CRLF and space..

How to use string.split() for both CRLF and whitespace ? Do I need regexp?

From stackoverflow
  • Unfortunately AS3 does not allow you to split after an array of chars, like the classic OO languages (C#, Java, C++).

    You would have to use a RegExp for the second param of String.Split:

    \n Matches a newline character.

    \r Matches a return character.

    \t Matches a tab character.

    Tom : so what would be the whole regexp like split (a, "/\s+$/");
    Bogdan Gavril : you can use groups and the OR operator: |
  • text.split('\r\n').join('\r');
    text.split('\r').join('\r\n');

0 comments:

Post a Comment