I have created a javascript sort function to sort a list of articles by title. I am going to convert all of the sortable words to capital letters so I do not have to deal with the differences associated with lower case and upper case. I am having trouble creating an expression though that wipes out all characters before the word that are not [A-Z]. I am not very familiar with regular expressions and any help would be appreciated. I am looking for something like this…
function cleanup(e) {
// delete leading not alphanum characters
// capitalize for sorting
// str.replace(/^\s*/, '').replace(/\s*$/, '');
return(e);
}
If you use the
idelimiter, the regular expression will be case insensitive, you might use this when you compare words.Try this http://jsfiddle.net/5Rxs5/
Will replace all non a-zA-Z characters before the text:
If you want to remove all non a-zA-Z character do this (added the
gdelimiter, which means global):Uppercase first char
Alerts: