Wednesday, January 11, 2012

replace an 's' at the end of the word if there's not an 's' before it



.replace(/([^s]?s)$/, '')



I thought [^abc] meant "not any of these characters" but in the code above, it's replacing the s at the end of the word only if there's an s before it. How would I make this regex into: replace the s at the end of the word, only if there's no s before it?


No comments:

Post a Comment