Thursday, February 10, 2011

Javascript: split method can be used to split based on string or regular expression.

If you want to split a string based on another string, this how you do it:
str.split(" ");

If you want to split a string based on a reges, this how you do it:
str.split(/\s/);

\s is a reges which is used for any space character like space,\n,\t or \r.

No comments:

Post a Comment