帮助理解一个ereg表达 [英] help understanding an ereg expression

查看:64
本文介绍了帮助理解一个ereg表达的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有以下脚本:


< ;?

$ string =''test'';

if(eregi(" ^ [a-z0-9 | | \,\-\ + \。] + $",$ string))

{

echo''匹配!'';

}

其他

{

echo''没有匹配'';

}

?>


为什么$ string =''te\st''产生一场比赛? ereg的表达并不是
里面有一个\\ ...


此外,什么是| |做?通常,它的意思是''或'',但是在[]的内部?

和其中两个?

Say I have the following script:

<?
$string = ''test'';
if (eregi("^[a-z0-9| |\,\-\+\.]+$",$string))
{
echo ''matches!'';
}
else
{
echo ''no match'';
}
?>

Why does $string = ''te\st'' yield a match? The ereg expression doesn''t
have a \\ in it...

Also, what does | | do? Normally, it''d mean ''or'', but inside of []''s?
And two of them?

推荐答案

string =''test'';

if(eregi(" ^ [a-z0-9 | | \,\-\ + + \。] +
string = ''test'';
if (eregi("^[a-z0-9| |\,\-\+\.]+


",


string))

{

echo''匹配!'';

}

其他

{

echo''不匹配'' ;

}

?>


为什么
string))
{
echo ''matches!'';
}
else
{
echo ''no match'';
}
?>

Why does


这篇关于帮助理解一个ereg表达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆