I am trying to get rid of the delimited text.
For Example: "this#101# is#102# a#103# test#104#"
Result : "this is a test"
Tried the Following which didn;t Work
string Pattern = @"(?<=#).*(?=#;)";
string text = "this#101# is#102# a#103# test#104#";
text = Regex.Replace(text, Pattern, string.Empty);
Try:
string Pattern = @"#.*?#";
Since you need to get rid of the #
too, you need to specify them as matching part of the regex. Your current regex does not match the #
.
Also you need to make the .*
match non-greedy by adding a trailing ?
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.