Fix DoROReplaceWords So that parts of words are not affected
This commit is contained in:
parent
42ba094c03
commit
85771b0dda
@ -538,15 +538,30 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
return text;
|
||||
}
|
||||
private string DoROReplaceWords(ReplaceStrList replaceStrList, string newvalue, bool isHigh)
|
||||
private string DoROReplaceWords(ReplaceStrList replaceStrList, string oldvalue, bool isHigh)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> DoROReplaceWords");
|
||||
string newvalue = oldvalue;
|
||||
foreach (ReplaceStr rs in replaceStrList)
|
||||
{
|
||||
if (((rs.Flag & E_ReplaceFlags.Setpoint) > 0) || (isHigh && (rs.Flag & E_ReplaceFlags.HLSSetpnt) > 0))
|
||||
{
|
||||
newvalue = newvalue.Replace(rs.ReplaceWord, rs.ReplaceWith);
|
||||
try
|
||||
{
|
||||
// Use regular expression to assure that the ReplaceWord is not part of another word
|
||||
// For VEPROMS_CAL E-0 Step 23 (Reset SI) the word "after" was being changed to "aFTer"
|
||||
newvalue = Regex.Replace(newvalue, @"(?<=\W|^)" + rs.ReplaceWord + @"(?=\W|$)", rs.ReplaceWith);
|
||||
//newvalue = newvalue.Replace(rs.ReplaceWord, rs.ReplaceWith);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_MyLog.Warn("Problem with regular expression", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (oldvalue != newvalue)
|
||||
// Console.WriteLine("\"{0}\"\r\n\"{1}\"",oldvalue,newvalue);
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
return newvalue;
|
||||
}
|
||||
// Replace spaces with hardspaces, but DO NOT replace the end of an Rtf Command with a hardspace
|
||||
|
Loading…
x
Reference in New Issue
Block a user