-1

Python regex to replace non ASCII characters such as long dash ,  ,etc. with single hyphen from text file sample.txt

  • 1
    Does this answer your question? [Replace non-ASCII characters with a single space](https://stackoverflow.com/questions/20078816/replace-non-ascii-characters-with-a-single-space) – Booboo May 12 '20 at 10:24

1 Answers1

0

You don't need Regex for any of your code, something like this would suffice:

forbidden_chars = 'abcd'
text = 'abcdefghijklmnop....'

for i in forbidden_chars:
    text = text.replace(i, '-')

print(text)
>>>-----efghijklmnop....
Krish
  • 1,044
  • 9
  • 20