Remove punctuation from string with Regex

First, please read here for information on regular expressions. It’s worth learning.

You can use this:

Regex.Replace("This is a test string, with lots of: punctuations; in it?!.", @"[^\w\s]", "");

Which means:

[   #Character block start.
^   #Not these characters (letters, numbers).
\w  #Word characters.
\s  #Space characters.
]   #Character block end.

In the end it reads “replace any character that is not a word character or a space character with nothing.”

error code: 523