我在做PHP中的字符串解析问题。我想要一个字典中的单词的正则表达式。这个词只能包含A-Z和a-z。我想出了这个正则表达式,但这似乎不起作用。有人可以帮忙吗?对于eadibility正则表达式的一个字
$regexp = "/[A-z]+/";
if(preg_match($regexp,$buffer)){
print $buffer . "<BR>";
}
添加RKT的评论目前正在使用此正则表达式
$regexp = "/[A-Za-z]+/";
但仍许多不着边际的话越来越打印,对于如。
a.new,#quickbar a.new{color:#ba0000} enwiki:resourceloader:filter:minify-css:5:f2a9127573a22335c2a9102b208c73e7 wgNamespaceNumber=0;
wgAction="view";
wgPageName="Roger_Federer";
wgMainPageTitle="Main Page";
wgWikimediaMobileUrl="http:\/\/en.m.wikipedia.org\/wiki";
document.writeln("\x3cdiv id=\"localNotice\"\x3e\x3cp\x3e\x3c/p\x3e\n\x3c/div\x3e");
你的意思是说一个字还是至少一个字?如果有一个词,你写的内容会匹配,即使还有其他内容。 – 2011-06-10 00:07:42
什么,确切地说,不工作? – moteutsch 2011-06-10 00:08:48
目前使用这个正则表达式$ regexp =“/ [A-Za-z] + /”; 但仍然有很多不相关的单词正在打印,例如。 a.new,#quickbar a.new {color:#ba0000} enwiki:resourceloader:filter:minify-css:5:f2a9127573a22335c2a9102b208c73e7 wgNamespaceNumber = 0; wgAction =“view”; wgPageName =“Roger_Federer”; wgMainPageTitle =“Main Page“; wgWikimediaMobileUrl =”http:\/\/en.m.wikipedia.org \/wiki“; document.writeln(“\ x3cdiv id = \”localNotice \“\ x3e \ x3cp \ x3e \ x3c/p \ x3e \ n \ x3c/div \ x3e”); – rkt 2011-06-10 00:16:38