I am trying to write a Regex pattern to modify the caption of my datagridview.
I need to remove following characters from each string:
space
[
]
*
#
?
/
\
@
(
)
.
“”
”
I am super confused and I need your help in defining the patter of the Regex in C#. This is my sample code:
DataTable d_new = d;
for (int i = 0; i < d.Columns.Count; i++)
{
string t = d.Columns[i].Caption;
string regex = "\\s+"; // this needs to Be expanded
string t_new = Regex.Replace(t, regex, "_");
d.Columns[i].Caption = t_new;
}
1 Answer