Microsoft
Software
Hardware
Network
Question : Regex.Replace only match entire word instead of part of a word
Hi,
I have a problem with the following code :
Function StripHighlightHTML(ByVal InputTxt As String) As String
Dim pattern As String = "<(.|\n)*?>"
Dim clearhtml, Search_Str As String
Search_Str = Request.QueryString("Searc
h")
clearhtml = Regex.Replace(InputTxt, pattern, String.Empty)
Return Regex.Replace(clearhtml, "\b(" & Search_Str & ")\b", "
>" & "$1" & "
", RegexOptions.IgnoreCase)
End Function
The codes replace html to plain text and then scans it for search tekst to get highlighted.
The codes worksp perfectly BUT it only highlights if it match the entire word instead of a word part.
Something i have to add here : "\b(" i think. Anyone has an idea ?
Answer : Regex.Replace only match entire word instead of part of a word
Hi,
\b means word boundary, so "\b(" & Search_Str & ")\b" means match whole words only. Remove both \b and it should match part of the word.
/peter
Random Solutions
What’s the SMTP verb used for public folder replications?
KDC Service Hung - Event ID: 7022 - SBS2003
W3WP crashing windows server 2003 and 2008 and iis6 and iis7
Unable to open <a rel="nofollow" href="http://" target="_blank">http://</a>.... Cannot download the information you requested
Open database .mssql type
DoCmd.RunApp ???
Left and right keys are reversed in excel text boxes
access run-time for 2003,Execution of this application has stopped due to a run-time error
MAX value of a column
Combobox with an array that gets lengthened