Forum Moderators: open
What I have below is what I wrote so far and works great, but it is just a replacer. I want to use [url] & [/url] and haven't figured out how to do it. I guess I need to capture the characters between the two tags.
<%
Dim text1
text1 = Request.Form("body")
Response.Write(TextConvert(text1))
FUNCTION TextConvert(text)
'Basic HTML Convert
symbols = "[b],<b>;[/b],</b>;[i],<i>;[/i],</i>;[u],<u>;[/u],</u>;[center],<center>;[/center],</center>;[sup],<sup>;[/sup],</sup>;[sub],<sub>;[/sub],</sub>;[1],<font size=1>;[/1],</font>;[2],<font size=2>;[/2],</font>"
FOR EACH symbol in Split(symbols, ";")
sym = Split(symbol, ",")
text = Replace(text, sym(0), sym(1))
NEXT
'Keep Breaks
text = Replace(text, chr(10) & chr(13), "<br>")
TextConvert = text
END FUNCTION
%>
Any ideals? Is there an easier way of doing it?
FUNCTION TextConvert(text)'Basic HTML Convert
symbols = "[b,<b;[/b,</b;[i,<i;[/i,</i;[u,<u;[/u,</u;[center,<center;[/center,</center;[sup,<sup;[/sup,</sup;[sub,<sub;[/sub,</sub;[1,<font size=1;[/1,</font;[2,<font size=2;[/2,</font"symbols = symbols & ";],>"
...
If you're working with .NET, you might be better served using the RegEx.Replace(...) method. That way, you don't have to list out all the tags, either - you can just go through your resultant string and replace illegal tags (maybe <script>). Don't know if this method is available in ASP?
hth,
g.