regex - Javascript replace all characters that are not a-z OR apostrophe -
i have around interwebs have yet find solid answer. seems pretty straight forward. let want replace characters in string not a-z , not , apostrophe. example:
with string "jeni's splendid ice cream" replace characters not a-z or apostrophe. have tried far is:
var term = "jeni's splendid ice cream" term.tolowercase().replace(/[^a-z]|[^\']/g, '');
but didn't seem work.... correct everyone? need sanity check, lol
or statements (|
) belong inside group, in case unnecessary. regex should trick:
/[^a-z']/g
working example:
var term = "jeni's splendid ice cream" alert(term.tolowercase().replace(/[^a-z']/g, ''));
Comments
Post a Comment