您的位置:程序门 -> .net技术 -> c#



一个正则的问题


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


一个正则的问题[已结贴,结贴人:ratooner]
发表于:2007-03-29 17:43:53 楼主
<tr>
<th   class=time> 编号 </th>
<th   class=team> 名字 </th> <!-- <th> 别名 </th> -->
<th   class=pr> 性别 </th>
<th   class=ou> 出生 </th>
<th> 地址 </th> </tr>

请问怎么匹配上面的字符呀
发表于:2007-03-29 17:59:501楼 得分:0
<tr>
<th   class=time> 编号 </th>
<th   class=team> 名字 </th> <!-- <th> 别名 </th> -->
<th   class=pr> 性别 </th>
<th   class=ou> 出生 </th>
<th> 地址 </th> </tr>

这样就可以了-_-###

问题是你想要匹配什么啊,提取表格中每个单元格的内容吗,你给的是一个表头,内容未必是这种格式的,贴表格内容,说你想要的结果
发表于:2007-03-29 18:38:372楼 得分:0
匹配 <tr> ..... </tr> 这类的表头
发表于:2007-03-29 18:45:223楼 得分:0
不知道你是什么目的,这样试下吧,使用的时候加上regexoptions.ignorecase参数以忽略大小写

<tr> \s* <th[\s\s]*? </th> \s* </tr>
发表于:2007-03-29 19:27:454楼 得分:0
not   match   found   ,用正则测试不行呢
发表于:2007-03-29 19:47:005楼 得分:20
用vs.net测试,加上regexoptions.ignorecase参数,如果你是用正则工具测试,看看有没有忽略大小写的选项,如果没有,那就把上面的正则里小写字母全都转成大写字母再测试,算了,写个吧

<tr> \s* <th[\s\s]*? </th> \s* </tr>
发表于:2007-03-29 20:07:246楼 得分:0
not   match   found,还是不行,不信你测试一下
发表于:2007-03-29 20:09:167楼 得分:0
如果加上ignorepatternwhitespace,就可以
发表于:2007-03-29 20:14:318楼 得分:0
我的测试代码,结果为包含

string   yourstr   =   richtextbox1.text;
if   (regex.ismatch(yourstr,   @ " <tr> \s* <th[\s\s]*? </th> \s* </tr> ",   regexoptions.ignorecase))
{
        richtextbox2.text   =   "包含 ";
}
else
{
        richtextbox2.text   =   "不包含 ";
}

贴你的测试代码,如果测试用字符串不是上面的,一起贴出来
发表于:2007-03-29 22:01:119楼 得分:0
在vs.net测试通过,怎么在正则测试器里面不通过呢
string   a=@ " <tr>
<th   class=time> 编号 </th>
<th   class=team> 名字 </th> <!-- <th> 别名 </th> -->
<th   class=pr> 性别 </th>
<th   class=ou> 出生 </th>
<th> 地址 </th> </tr> ";
if   (regex.ismatch(a,   @ " <tr> \s* <th[\s\s]*? </th> \s* </tr> ",   regexoptions.ignorecase))
{
messagebox.show(   "包含 ");
}
else
{
messagebox.show(   "不包含 ");
}
发表于:2007-03-29 22:21:0310楼 得分:0
有的时候正则工具和vs.net的测试结果还是有差别的,尤其是涉及到加参数的时候


快速检索

最新资讯
热门点击