diff --git a/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs b/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs index 443d8dd..0a041ff 100644 --- a/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs +++ b/ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs @@ -41,10 +41,14 @@ public void OnSelectionChanged(TextManager textManager, int nStart, int nLen) { } return false; }); - if (!string.IsNullOrEmpty(strKey)) { + if (!string.IsNullOrEmpty(strKey)) { string strText = textManager.GetText(); List lst = new List(); - foreach (Match m in Regex.Matches(strText, "\\b" + strKey + "\\b")) { + if ("* . ? + $ ^ [ ] ( ) { } | \\ /".Split(' ').Contains(strKey)) + { + strKey = "\\" + strKey; + } + foreach (Match m in Regex.Matches(strText, "\\b" + strKey + "\\b")) { // * . ? + $ ^ [ ] ( ) { } | \ / lst.Add(new TextStyleRange() { Index = m.Index, Length = m.Length,