正则表达式语法基础知识 [英] regular expression syntax basics
本文介绍了正则表达式语法基础知识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试匹配顶级域名,其中$ sub =顶级域名
if(eregi(" ^ com $ | ^ org $ | ^ net) $ | ^ biz $ | ^ info $ | ^ edu $ | ^ gov $ | ^ int $ |
^ mil $",$ sub))
{
在这里做什么
}
我试过单独引用每一个(" ^ com $ " |" ^ net $" | ...)但
也不起作用。如何在这里使用报价?应该
我使用单引号?有什么区别?
I''m trying to match top-level domains, where $sub = top level domain
if ( eregi("^com$ | ^org$ | ^net$ | ^biz$ | ^info$ | ^edu$ | ^gov$ | ^int$ |
^mil$", $sub) )
{
do stuff here
}
I''ve tried quoting each one individually ( "^com$" | "^net$" | ... ) but
that does not work either. How are quotes supposed to be used here? Should
I use a single quote? What''s the difference?
推荐答案
sub =顶级域名
if(eregi(" ; ^ com
sub = top level domain
if ( eregi("^com
| ^ org
| ^ net
这篇关于正则表达式语法基础知识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文