View Full Version : Replacing tags
telmessos
01-07-2007, 07:33 PM
Hi everybody,
I would like to know how I can separate a special tag created by me from an info coming from database. For example:
if the text is
This is a test message. This point is the part where we get the link
How can I replace [link=default.asp] tag with <a href="default.asp"> tag???
bostjank
01-08-2007, 10:37 PM
sText = "This is a test message. This point is the part where we get the link"
sText = Replace(sText,"","<a href=""default.asp"">")
sText = Replace(sText,"","</a>")
degsy
01-12-2007, 03:04 PM
Also look into bbcode scripts as they will give you an idea of using regex to parse the text into links.
<%
'----------------------------------------
' Common Regular Expression Function
'----------------------------------------
Function ReplaceRegExp(strString, strPattern, strReplace)
Dim RE: Set RE = New RegExp
With RE
.Pattern = strPattern
.Global = True
ReplaceRegExp = .Replace(strString, strReplace)
End With
End Function
'----------------------------------------
' Turn BBcode into HTML
'----------------------------------------
Function BBCodeToHTML(strString)
strString = ReplaceRegExp(strString, "\]*)\]([^\[]*)\[/link\]", "<a href=""$1"">$2</a>")
BBCodeToHTML = strString
End Function
str = "hello there this is a [link=default.asp]link"
Response.Write BBCodeToHTML(str)
%>
http://forums.aspfree.com/code-bank-54/simple-bbcode-script-90019.html
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.