Remove Symbols

Sat 17 May 2025

title: "Remove Symbols" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


content = "This device is costing only 12.89$. This is fantastic!"
content
'This device is costing only 12.89$. This is fantastic!'
import re
re.sub(r'[^\w]', ' ', content)
'This device is costing only 12 89   This is fantastic '

Note:

\w will match alphanumeric characters and underscores

[^\w] will match anything that's not alphanumeric or underscore



Score: 5

Category: regex