tags:

views:

1152

answers:

2

In C#, I want to be able to generically replace text, ignoring case in the search but not in the replace (kind of?). Here is an example:

I have a list that looks like this:

Site -> Place

Stuff -> Things

etc...

Then I want to call ConvertMyString("Site") and have it return "Place".

So far I have this working, BUT...

If I call ConvertMyString("site"), I would like it to return "place" (lowercase).

Is there an easy way to do this with a RegEx or something without having to put all uppercase and lowercase versions in the list?

+3  A: 

You could use a MatchEvaluator to manipulate the replacement string? It gets handed the matched string so you could look at the case of that and assemble a replacement. Seemsa bit overkill, though

Paul
A: 

or use this online tool: http://gskinner.com/RegExr/

Fleents