views:

134

answers:

1

I am working on a wiki bot for my communities wiki that uses the DotNetWikiBot Framework; it is to find a word that is commonly a typo (such as "abilty") and replaces them with the correction (such as "ability").

This works as is is coded:

p.text = p.text.Replace(@"\b" + typoArray[x, 0] + @"\b", typoArray[x, 1]);

However this will replace "Abilty" with "ability" which is of course going to cause issues, but I cannot figure out how to preserve the case of the replaced word (so Abilty becomes Ability) unless the typo replacement is meant to be capitalized, no matter what it is replacing: januray to January

+1  A: 

I think you will do better using Regular Expressions from the System.Text.RegularExpressions namespace.

Regex.Replace(str, "[A]", "Z"); or some variant of it. Regular expressions are powerful.

Lobuno
Thanks, your answer lead me down the right psth to find what I needed.
Josh King