javascriptOctober 6, 2006 6:55 pm
RegExp Pattern To Split A String
If you have a string with possible multiple spaces between words, and you want to convert the string to an array, use a split() method with the following regular expression : /\s*/ .
Example:
var str = "aa bb cc dd";
var ar = str.split(/ \s*/);
The resulting array will contain 4 elements : aa, bb, cc, dd.
A pattern to strip tags:
str.replace(/<\/?[^>]+>/gi, ‘’);
Have not checked it yet. It is being used in the prototype library.
