Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11691

C#: Regex.replace

$
0
0

I have a string that I would like to apply regex pattern and replace a part of it. I am able to accomplish some part of what I would like to do. My code is:

var str = "license plate matching AMC1";var result = Regex.Replace(str, "matching|matches|match", $"like");var result1 = Regex.Replace(result, "[a-zA-Z0-9]+$", "\'%$1%\'");Console.WriteLine(result1);

I would like to replace the substring AMC1(an alpha numeric) with '%AMC1%'. How do I accomplish this?


Viewing all articles
Browse latest Browse all 11691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>