preg_match没有给出期望结果的问题。 [英] Problem with preg_match not giving desired result.
本文介绍了preg_match没有给出期望结果的问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我正在使用preg_match函数来搜索字符串。
我想要的结果是$ rollno = 0710或7109或109或071或710给出它将返回true否则为false。
我的代码是
展开 | 选择 | Wrap | 行号
解决方案
rollno = 0710或7109或109或071或710,它将返回true,否则为false。
我的代码是
展开 | 选择 | Wrap | 行号
那是因为你寻找一个5位数字。你似乎把OR运算符(|)与一个字符类([])混淆。
这是我的代码:
展开 < span class =codeDivider> | 选择 | Wrap | Line编号跨度>
Hello ,
I am using preg_match function to search a string.
My desired result would be if $rollno=0710 or 7109 or 109 or 071 or 710 is given it would return true else false.
My code is
Expand|Select|Wrap|Line Numbers解决方案rollno=0710 or 7109 or 109 or 071 or 710 is given it would return true else false.
My code is
Expand|Select|Wrap|Line Numbers
that?s because you look for a 5 digit number. you seem to confuse the OR operator (|) with a character class ([]).
This is my code :
Expand|Select|Wrap|Line Numbers
这篇关于preg_match没有给出期望结果的问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文登录 关闭
扫码关注1秒登录发送“验证码”获取 | 15天全站免登陆