finding punctuations except for – regex

so I was trying to get rid of words that have punctuations except for -.I was trying to use .match() from string and delete the whole string if it’s false. I tried


but it won’t recognize -.

so “he789llo” should be deleted but “he-llo” shouldn’t be.but both words were being deleted by the regex

Source: regex

Leave a Reply