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.
Thursday, February 10, 2011
Javascript: split method can be used to split based on string or regular expression.
Labels:
javascript,
regex,
regular expression,
split,
string
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment