Thành viên | Nội dung |
linux
ubuntu 33 bài
| private string RegexReplace(string content, string pattern, string rep) { Regex regx = new Regex(pattern, RegexOptions.IgnoreCase); content = regx.Replace(content, ""); return content; }
private string RemoveSpace(string content) { while (content.IndexOf(" ") > -1) content = content.Replace(" ", " "); return content; }
content = RegexReplace(content, "<(.|\n)*?>", " "); content = RemoveSpace(content); content = content.Replace("\r", "").Replace("\t", ""); content = RegexReplace(content, " ", " ");
|
tieubavuong
9 bài
| Em góp với http://www.mediafire.com/file/ddywu35gk5j/HtmlRemoval.cs
using System; using System.Text.RegularExpressions;
/// <summary> /// Methods to remove HTML from strings. /// </summary> public static class HtmlRemoval { /// <summary> /// Remove HTML from string with Regex. /// </summary> public static string StripTagsRegex(string source) { return Regex.Replace(source, "<.*?>", string.Empty); }
/// <summary> /// Compiled regular expression for performance. /// </summary> static Regex _htmlRegex = new Regex("<.*?>", RegexOptions.Compiled);
/// <summary> /// Remove HTML from string with compiled Regex. /// </summary> public static string StripTagsRegexCompiled(string source) { return _htmlRegex.Replace(source, string.Empty); }
/// <summary> /// Remove HTML tags from string using char array. /// </summary> public static string StripTagsCharArray(string source) { char [] array = new char [source.Length] ; int arrayIndex = 0; bool inside = false;
for (int i = 0; i < source.Length; i++) { char let = source [ i ] ; if (let == '<') { inside = true; continue; } if (let == '>') { inside = false; continue; } if (!inside) { array [arrayIndex] = let; arrayIndex++; } } return new string(array, 0, arrayIndex); } }
/** *created by tieubavuong@updatesofts.com *copyright TriNam, TDI, JSC *http://trinam.com.vn */
---
|
awas
54 bài
| Em góp với http://www.mediafire.com/file/ddywu35gk5j/HtmlRemoval.cs using System; using System.Text.RegularExpressions;
/// <summary> /// Methods to remove HTML from strings. /// </summary> public static class HtmlRemoval { /// <summary> /// Remove HTML from string with Regex. /// </summary> public static string StripTagsRegex(string source) { return Regex.Replace(source, "<.*?>", string.Empty); }
/// <summary> /// Compiled regular expression for performance. /// </summary> static Regex _htmlRegex = new Regex("<.*?>", RegexOptions.Compiled);
/// <summary> /// Remove HTML from string with compiled Regex. /// </summary> public static string StripTagsRegexCompiled(string source) { return _htmlRegex.Replace(source, string.Empty); }
/// <summary> /// Remove HTML tags from string using char array. /// </summary> public static string StripTagsCharArray(string source) { char [] array = new char [source.Length] ; int arrayIndex = 0; bool inside = false;
for (int i = 0; i < source.Length; i++) { char let = source [ i ] ; if (let == '<') { inside = true; continue; } if (let == '>') { inside = false; continue; } if (!inside) { array [arrayIndex] = let; arrayIndex++; } } return new string(array, 0, arrayIndex); } }
/** *created by tieubavuong@updatesofts.com *copyright TriNam, TDI, JSC *http://trinam.com.vn */
---
Ổn đấy đồng chí ---
|
aspnet
Lập trình không biên giới 598 bài
| public static string RemoveHTML(string input) { // remove comments input = Regex.Replace(input, "<!--(.|\\s)*?-->", string.Empty); // remove HTML return Regex.Replace(input, "<(.|\\s)*?>", string.Empty); }
bổ xung thêm cho anh em --- Coding for food http://yenbai.awas.vn http://tknd.vn http://coder.awas.vn http://awas.vn http://bieuquyet.vn http://webhocsinh.com
|
lyngochung
17 bài
| Các bác cho em hỏi cái:
1. Em có cái chuỗi đầu vào như đoạn sau #subnet 172.20.192.0 netmask 255.255.192.0 { # range 172.20.192.10 172.20.255.254; # option routers 172.20.192.1; #} subnet 172.20.192.0 netmask 255.255.248.0 { range 172.20.192.10 172.20.199.254; option routers 172.20.192.1; } subnet 172.20.200.0 netmask 255.255.252.0 { range 172.20.200.10 172.20.203.254; option routers 172.20.200.1; } 2. Bây giờ em muốn dùng Regular expression để lọc ra tất cả các nhóm như subnet 172.20.192.0 netmask 255.255.248.0 { range 172.20.192.10 172.20.199.254; option routers 172.20.192.1; }. Nếu trong nhóm này mà có dấu # ở trong thì không bắt lấy. Như vậy trong đoạn chuỗi trên em chỉ cần lấy 2 nhóm sau thui, mong các bác help me !
|
|