Convert plain text to Clickable link or PlainText link in asp.net
I need your advice on converting plain text to URL.
The script will be like this: the user selects a post, and then the "convert to link" button.
The input text that the user selected is converted to (link: selected_text)
. I am doing this with JavaScript. And after that, when he clicks the Save button to save his entire record, I don't know how to store (link: selected_text)
in that database.
The URL will look like this: www.mysite.aspx?t=selected_text
.
I can convert (link: selected_text)
using the encoded replace function. But then I don't know how to show the user as interactive and also not show<a href="www.mysite.aspx?t=selected_text">
This can be difficult to understand, so I'll show some of my codes to explain.
Private Sub Save(ByVal Entry As String) ' Entry Comes from entry textbox '
Dim elected As String
selected = Entry.Replace("(link: ", "<a href http://www.mysite.com?link=")
selected = Entry.Replace(")", ">")
' then here starts save but not necessary to show '
End Sub
Save the message when the user wrote it. This will make it easier to edit the post later. When you post, you must use a regular expression to replace it with a real link. You should never replace all ")" with ">". What happens if I write "hello (world)"?
Result: Hello (world>
You can find some great regular expressions here: http://regexlib.com
source to share