I want to strip off the 're:' off subject lines in emails:
My string helper extension does the following:
return Regex.Replace(value, "([re:][re :])", "",RegexOptions.IgnoreCase);
However, it seems to match on "re :", but not "re开发者_开发技巧:".
You probably mean something like:
Regex.Replace(value, "re:|re :", "", RegexOptions.IgnoreCase);
Which can also be written as:
Regex.Replace(value, "re ?:", "", RegexOptions.IgnoreCase);
And here is a possibly better expression:
Regex.Replace(value, "^\s*re\s*:\s*", "", RegexOptions.IgnoreCase);
Which only matches at the beginning of the string (^) and also removes any following spaces (\s*).
加载中,请稍侯......
精彩评论