tefos666
جمعه 11 دی 1388, 13:00 عصر
سلام دوستان ، کسی میتونه کمک کنه و سورس این تیکه برنامه رو برام بنویسه ؟
یک richtextbox میخوام که توش یکسری tag برای HTML نوشتم میخوام وقتی روی یک دکمه کلیک کردم بره تمام tag هایی که مشکل داره رو درست کنه یا bold کنه ، خودم به این نتیجه رسیدم که با Regular Expressions (http://www.zytrax.com/tech/web/regex.htm) ها بنویسم ولی نتونستم link های زیادی هم پیدا کردم ، ظاهرا بهترینش لینک زیر بود ولی موفق نشدم اینو بنویسم ، لطفا کمک کنید ، شدیدا نیاز دارم
http://regexlib.com/Search.aspx?k=html+tags&c=-1&m=-1&ps=20
اینم کدم
public string sPattern = "<(/)?(a|abbr|acronym|address|applet|area|b|base|basef ont|bdo|big|blockquote|body|br|button|caption|cent er|cite|code|col|colgroup|dd|del|dir|div|dfn|dl|dt |em|fieldset|font|form|frame|frameset|h[1-6]|head|hr|html|i|iframe|img|input|ins|isindex|kbd|l abel|legend|li|link|map|menu|meta|noframes|noscrip t|object|ol|optgroup|option|p|param|pre|q|s|samp|s cript|select|small|span|strike|strong|style|sub|su p|table|tbody|td|textarea|tfoot|th|thead|title|tr| tt|u|ul|var|xmp){1}((\"[^\"]*\"*|[^>])*)*>";
private void RegExChecker()
{
try
{
if (Regex.IsMatch(richTextBox1.Text, sPattern))
{
TxtResult.Text = "\n"+" ";
CheckTag();
}
else
{
TxtResult.Text = "\n" + " ";
DialogResult objResult;
objResult = MessageBox.Show(" ", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (objResult == DialogResult.No)
{
return;
}
else
{
// این قسمت واسه هایلایت کردن تگ هاست و زیاد مهم نیست ، باید کد مورد نظر رو اینجا بنویسم
r.Matches(@"<TAG\b[^>]*>(.*?)</TAG>");
Parse();
richTextBox1.TextChanged += new EventHandler(this.TextChangedEvent);
}
اگر سوال اول رو نتونستید جواب بدید لطفا اینو حل کنید
اصلا میشه line های richtextbox رو توی یه حلفه بزارم دونه دونه tag ها رو با یک regular پیدا کنه و بریزه تو یه مقدار و اونو چک کنم ؟
یک richtextbox میخوام که توش یکسری tag برای HTML نوشتم میخوام وقتی روی یک دکمه کلیک کردم بره تمام tag هایی که مشکل داره رو درست کنه یا bold کنه ، خودم به این نتیجه رسیدم که با Regular Expressions (http://www.zytrax.com/tech/web/regex.htm) ها بنویسم ولی نتونستم link های زیادی هم پیدا کردم ، ظاهرا بهترینش لینک زیر بود ولی موفق نشدم اینو بنویسم ، لطفا کمک کنید ، شدیدا نیاز دارم
http://regexlib.com/Search.aspx?k=html+tags&c=-1&m=-1&ps=20
اینم کدم
public string sPattern = "<(/)?(a|abbr|acronym|address|applet|area|b|base|basef ont|bdo|big|blockquote|body|br|button|caption|cent er|cite|code|col|colgroup|dd|del|dir|div|dfn|dl|dt |em|fieldset|font|form|frame|frameset|h[1-6]|head|hr|html|i|iframe|img|input|ins|isindex|kbd|l abel|legend|li|link|map|menu|meta|noframes|noscrip t|object|ol|optgroup|option|p|param|pre|q|s|samp|s cript|select|small|span|strike|strong|style|sub|su p|table|tbody|td|textarea|tfoot|th|thead|title|tr| tt|u|ul|var|xmp){1}((\"[^\"]*\"*|[^>])*)*>";
private void RegExChecker()
{
try
{
if (Regex.IsMatch(richTextBox1.Text, sPattern))
{
TxtResult.Text = "\n"+" ";
CheckTag();
}
else
{
TxtResult.Text = "\n" + " ";
DialogResult objResult;
objResult = MessageBox.Show(" ", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (objResult == DialogResult.No)
{
return;
}
else
{
// این قسمت واسه هایلایت کردن تگ هاست و زیاد مهم نیست ، باید کد مورد نظر رو اینجا بنویسم
r.Matches(@"<TAG\b[^>]*>(.*?)</TAG>");
Parse();
richTextBox1.TextChanged += new EventHandler(this.TextChangedEvent);
}
اگر سوال اول رو نتونستید جواب بدید لطفا اینو حل کنید
اصلا میشه line های richtextbox رو توی یه حلفه بزارم دونه دونه tag ها رو با یک regular پیدا کنه و بریزه تو یه مقدار و اونو چک کنم ؟