Fixed code that converts the search string into a regular expression search string. This fixed a number of problems including the search for the percent symbol as described in B2012-089.

This commit is contained in:
Rich 2012-03-26 13:32:45 +00:00
parent a38a883170
commit 27c6c39fbc

View File

@ -549,11 +549,16 @@ namespace Volian.Print.Library
if (_RegexSearchString == null) if (_RegexSearchString == null)
{ {
_RegexSearchString = _SearchString; _RegexSearchString = _SearchString;
if (_RegexSearchString[0] == '%') // Make it match the smallest matching string
_RegexSearchString = _RegexSearchString.Substring(1); _RegexSearchString = _RegexSearchString.Replace("*", ".*?");
if (_RegexSearchString[_RegexSearchString.Length - 1] == '%') // If search string starts with a wildcard use the beginning of line token (^)
_RegexSearchString = _RegexSearchString.Substring(0, _RegexSearchString.Length - 1); if (_RegexSearchString.StartsWith(".*?"))
_RegexSearchString = _RegexSearchString.Replace("%", ".*"); _RegexSearchString = "^" + _RegexSearchString;
// If search string ends with a wildcard use the end of line token ($)
if(_RegexSearchString.EndsWith(".*?"))
_RegexSearchString = _RegexSearchString+"$";
_RegexSearchString = _RegexSearchString.Replace("[", @"\[");
_RegexSearchString = _RegexSearchString.Replace("]", @"\]");
} }
return _RegexSearchString; return _RegexSearchString;
} }