Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert this Python punctuation-stripping function to JavaScript?

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, '')
like image 929
Ayaz Alavi Avatar asked Sep 17 '26 01:09

Ayaz Alavi


1 Answers

function strip_punctuation(s) {
    return s.replace(/[,.":;!%$]/g, "");
}
like image 167
Matti Virkkunen Avatar answered Sep 18 '26 13:09

Matti Virkkunen