views:

742

answers:

2

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

+1  A: 

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.

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

text.split('\r\n').join('\r');
text.split('\r').join('\r\n');

mzx