The code for reading the [[ https://sourceforge.net/p/autowikibrowser/code/HEAD/tree/AWB/WikiFunctions/Parse/RegExTypoFix.cs | RegExTypoFix ]] seems to depend on only known attributes in the XML definition of a regexp. Would it be possible to modify the regexp so that other attributes can be added, even if they're not used by AWB?
It would allow defining other attributes that other tools could use: for example, an identifier for the regexp, a flag indicating if the fix can be applied automatically... It would be ufesul for me to implement T258889 for disabling specific regexp in WPCleaner, or other features I've in mind.
```
private static readonly Regex TypoRegex = new Regex("<(?:Typo)?\\s+(?:word=\"(.*?)\"\\s+)?find=\"(.*?)\"\\s+replace=\"(.*?)\"\\s*/?>", RegexOptions.Compiled);
```
**First proposition**
Allow any extra attributes after the 3 existing attributes (word, find, replace). Just replace the existing regular expression by:
```
private static readonly Regex TypoRegex = new Regex("<(?:Typo)?\\s+(?:word=\"(.*?)\"\\s+)?find=\"(.*?)\"\\s+replace=\"(.*?)\"(?:\\s+[a-z]+=\".*?\")*\\s*/?>", RegexOptions.Compiled);
```
I just added a non capturing group repeated 0 to n times `(?:\\s+[a-z]+=\".*?\")*` for extra attributes.
**Second proposition**
Allow any attributes in any order. The regular expression can be simplified:
```
private static readonly Regex TypoRegex = new Regex("<(?:Typo)?(?:\\s+([a-b]+)=\"(.*?)\")+\\s*/?>", RegexOptions.Compiled);
```
The regular expression will capture a series of `attribute name` and `attribute value`, so the code will need to be modified to extract the values for `word`, `find` and `replace`, and check that `find` and `replace` do exist. A suggested patch for the loop on the Matches (not tested or compiled):
```
foreach (Match m in TypoRegex.Matches(text))
{
String find = null;
String replace = null;
for (int i = 1; i < m.Groups.Length - 1; i += 2)
{
if (string.Equals("find", m.Groups[i].Value))
{
find = m.Groups[i + 1].Value;
}
if (string.Equals("replace", m.Groups[i].Value))
{
replace = m.Groups[i + 1].Value;
}
}
try
{
if (!string.isNullOrEmpty(find) && !string.isNullOrEmpty(replace))
{
typoStrings.Add(find, replace);
}
}
catch (ArgumentException)
{
RegExTypoFix.TypoError("Duplicate typo rule '" + find + "' found.");
return new Dictionary<string, string>();
}
}
```