|
-
Jul 9th, 2003, 09:56 PM
#1
Thread Starter
yay gay
Quoting system problem..
i am doing a kind of weblog in asp.net(using C#) but i am facing a problem..i want to put a quoting system..like this forum has..when the user puts [quote...[/quot..(i didnt put it so the forum didnt turn it into real quotes) it turns the thigns that are inside into a quote..my idea was when the user was posting the new it'd search for all the [quotes] and then would replace it for the HTML quote..but when adding it to the database(mssql 2k) i realised i couldnt do that because it wont accept me the ' symbol as it is a kind of"reserved word/simbol"..how should i do this? how the forums do this? thanks
\m/  \m/
-
Jul 9th, 2003, 11:07 PM
#2
Frenzied Member
My weblog http://blog.pjwc.com does what you are talking about. I got a piece of code from hellswraith that uses regular expressions to replace '[/quote] string and everything works fine when saving to the database. here is the code.
Code:
private string ProcessTags(string text)
{
// Encode the text.
text = System.Web.HttpUtility.HtmlEncode(text);
// replace the bold special tags
text = Regex.Replace(text, "\\[B\\]", "<b>", RegexOptions.IgnoreCase);
text = Regex.Replace(text, "\\[/B\\]", "</b>", RegexOptions.IgnoreCase);
// replace the underline special tags
text = Regex.Replace(text, "\\[U\\]", "<u>", RegexOptions.IgnoreCase);
text = Regex.Replace(text, "\\[/U\\]", "</u>", RegexOptions.IgnoreCase);
// replace the italic special tags
text = Regex.Replace(text, "\\[I\\]", "<i>", RegexOptions.IgnoreCase);
text = Regex.Replace(text, "\\[/I\\]", "</i>", RegexOptions.IgnoreCase);
// replace the URL tag
text = Regex.Replace(text, "\\[URL\\](?<url>.*)\\[/URL\\]", "<a href=\"${url}\" target=\"_blank\">${url}</a>", RegexOptions.IgnoreCase);
text = Regex.Replace(text, "\\[IMG\\](?<img>.*)\\[/IMG\\]", "<img src=\"${img}\"/>", RegexOptions.IgnoreCase);
// replace the EMAIL tag
text = Regex.Replace(text, "\\[EMAIL\\](?<email>.*)\\[/EMAIL\\]", "<a href=\"mailto:${email}\">${email}</a>", RegexOptions.IgnoreCase);
// replace the quote tags
text = Regex.Replace(text, "\\[QUOTE\\]", "<br><blockquote>quote:<hr height=\"1\" size=\"1\" noshade>", RegexOptions.IgnoreCase);
text = Regex.Replace(text, "\\[/QUOTE\\]","<hr height=\"1\" size=\"1\" noshade></blockquote><br>", RegexOptions.IgnoreCase);
// replace the new line and carriage return chars
text = text.Replace("\n", "<br>");
text = text.Replace("\r", "");
return text;
}
-
Jul 15th, 2003, 08:19 PM
#3
Thread Starter
yay gay
does anyone has a regular expression to the following format?
 Originally Posted by nick
msg
thanks
\m/  \m/
-
Jul 15th, 2003, 09:10 PM
#4
PowerPoster
This is what I use for my forums:
Code:
encodedString = Regex.Replace(encodedString, "\\[quote=((.|\n)*?)\\]((.|\n)*?)\\[/quote\\]", GetQuoteBlock(),RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static string GetQuoteBlock() {
StringBuilder sb = new StringBuilder();
sb.Append("<table width=90% cellspacing=1 cellpadding=3 border=0 align=center>");
sb.Append("<tr>");
sb.Append("<td><span class=StandardText><b>$1 wrote:</b></span></td>");
sb.Append("</tr>");
sb.Append("<tr>");
sb.Append("<td class=quote>$3</td>");
sb.Append("</tr>");
sb.Append("</table>");
return sb.ToString();
}
-
Jul 15th, 2003, 11:19 PM
#5
Thread Starter
yay gay
\m/  \m/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|