c# - Regular Expression Matching and Replacing -
c# - Regular Expression Matching and Replacing -
i have next regular look allows string contain alphabets, space, ,
, -
, ‘
:
^[a-za-z ,\‘-]*$
link demo
but want replace other character other mentioned in regex space. intending c# using regex.replace()
not working.
any suggestions helpful.
negate them!
[^a-za-z ,\‘-]
and replace space.
^
negates character class.
code:
var str = regex.replace("this ) content", @"[^a-za-z ,\‘-]", " ");
demo c# regex
Comments
Post a Comment