I use dynamically built regex. Problem is when symbol = "aaaa (1)" because regex tries to parse it, but I want to treat it literary
Regex regex = new Regex(@"(^" + "/(" + symbol + @" \(\d+\)$)|" + symbol);
You need to escape special chars:
var escapedSymbol = Regex.Escape(symbol);
Regex regex = new Regex(@"(^" + "/(" + escapedSymbol + @" \(\d+\)$)|" + escapedSymbol );
Reffer: msdn
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With