views:

103

answers:

1

Please can anyone translate this python code into javascript.

#
def strip_punctuation(s):
#
    for c in ',.":;!%$':
#
        while s.find(c) is not -1:
#
            s.replace(c, '')
+12  A: 
function strip_punctuation(s) {
    return s.replace(/[,.":;!%$]/g, "");
}
Matti Virkkunen
thanks. can u please tell me how to strip symbols and number from the string. I cant find regular expression for that
Ayaz Alavi
@Ayaz: Then, instead of looking for one, how about learning to write them yourself at http://www.regular-expressions.info/ ?
Matti Virkkunen