c# - remove character like |n, |p, |q from regex -
|p,|q string expression example "what |n abc |p"?
it can character after '|'
i tried
"[\\|.]"
but no success.
no need put |
, .
inside character class engine treat them literally. character class [\\|.]
searching 1 character out of \
, |
or .
(literally).
what want match on |.
(read: character |
, 1 other character after it).
string strregex = @"\|."; regex myregex = new regex(strregex, regexoptions.none); string strtargetstring = @"what |n abc |p"; string strreplace = @""; return myregex.replace(strtargetstring, strreplace);
every found match replaced nothing.
(code taken regexhero.net)
Comments
Post a Comment