Hello friends,
I have problems in using RegEx.replace method
with meta-characters.
For ex: Regex.Replace("**", "/t");
Sincae * is the part of RegEx syntex it throes some errors.
I tried with "//*" and it works. But I want use many meta-charecters.
Its a console application. I want the users to input search string and reolace string.
Ex:
repit ** /t
(Replaceing two astrics with tab)
Escaping meta chars is not helping here....
Any tips?
Loading
crauschPosted Sep 2, 2005, 2:18 PM
If you are storing the search and replace strings that the user types in then do something like this:
string result = Regex.Replace(someTextVar, Regex.Escape(userLookFor), userReplaceWith);
I would have to wonder though, are your users allowed to use wildcards or are all their "find" and "replaces" characters supposed to be literal character and not wildcards?