-4
String inputs ="td class=\"prodcatnamelinkwrap\"";
Pattern p = Pattern.compile("<td cellspacing=\"0\" align=\"center\" valign=\"bottom\" class=\"prodcatimagewrap\">");
Matcher m = p.matcher(inputs);
应该我想要做的,以匹配这种格式是什么。 任何一个帮助我 在此先感谢基于正则表达式匹配
查找方法如何工作。 我必须从该文本中匹配td height =“45px”valign =“top”
td align =“center”height =“45px”valign =“top”>。
但它说假
For reference please find my code
Pattern replace5 = Pattern.compile(".*\r?\n",Pattern.MULTILINE);
Matcher matcher5 = replace5.matcher("td[@height=\"45px\"][@valign=\"top\"]".replaceAll("[\\[\\@]+"," "));
pattern3 = Pattern.compile(matcher5.replaceAll(" ").replaceAll("\\//", "").replaceAll("\\]",""));
pm3 = pattern3.matcher("<td align="center" height="45px" valign="top">");
if(pm3.find())
....It always results in false.Can anyone help me out
你有没有交换与输入模式?当你的输入只是所需模式的一个子集时,说你想匹配这种格式是没有意义的。你想改变输入以匹配模式或改变模式以匹配输入。而不是只显示代码,添加一些你想要完成的信息。 – 2012-01-12 12:11:59
强制性:http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – Jonathan 2012-01-12 12:24:15
这么简单,因为它是我要检查网页内容
回答
不要重新发明轮子的所有时光。使用像jsoup这样的html解析器。
来源
2012-01-12 12:09:53 adatapost
作为简单,因为它是我想要查询的网页内容
我得到的fix.Below是解决方案:一个String = ”这是一个测试\ n \ n一些其他字符串
相关问题