The following regular expression works if there is no space character, but if the input has a space character, it doesn’t work (it seems like a link but JavaScript doesn’t work).
How can I change it?
The regular expression should work for both World and The World.
Dim makebkz As String Dim pattern As String = '\(bkz: ([a-z0-9$&.öışçğü\s]+)\)' Dim regex As New Regex(pattern, RegexOptions.IgnoreCase) Dim myAnchor As New System.Web.UI.HtmlControls.HtmlAnchor() Dim postbackRef As String = Page.GetPostBackEventReference(myAnchor, '$1') myAnchor.HRef = postbackRef str = regex.Replace(str, '(bkz: <a href=javascript:' & myAnchor.HRef & '><font color=''#CC0000''>$1</font></a> )') makebkz = str Return makebkz
I think this line should be changed:
If I read your code correctly you are including the $1 in the HRef (that’s what the Page.GetPostBackEventReference(myAnchor, ‘$1’) is doing), and then replacing it in both the text between the font tags and the href, so your output would be something like:
If you update your replace function to this, it should work:
I.e. wrap the javascript call in quotes, and your world will be good.