I have an a string that user may set and I would like to use that string inside pattern.
The pattern shall look like this "." + inputStr + "."
Though what if uses has regex specific charaters inside input. Pattern will break wouldnt it?
How can I create a pattern so that regex ignores what is inside inputStr?
Any ideas?
Try:
Regex.Escape(inputStr);
This should escape the string of any characters that would muck with your RegEx (and instead interpret those characters literally).
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