php - 为php结合两个正则表达式
问题描述
我有这两个正则表达式
^(((98)|(\+98)|(0098)|0)(9){1}[0-9]{9})+$
^(9){1}[0-9]{9}+$
如何将这些短语组合在一起?
有效电话:
just start with : 0098 , +98 , 98 , 09 and 9
sample :
00989151855454
+989151855454
989151855454
09151855454
9151855454
解决方案
你还没有提供什么通过和什么不通过,但我认为如果我理解正确的话,这将起作用......
/^\+?0{0,2}98?/
^ Matches the start of the string
\+? Matches 0 or 1 plus symbols (the backslash is to escape)
0{0,2} Matches between 0 and 2 (0, 1, and 2) of the 0 character
9 Matches a literal 9
8? Matches 0 or 1 of the literal 8 characters
推荐阅读
- deep-learning - 如何在 PyTorch 中实现时间分布密集(TDD)层
- java - 是否可以响应 http 错误,该代码在 java spring 中是可变的?
- r - 按一个值对 ggplot 轴重新排序,显示另一个值的标签
- java - 无法将 java.lang.String 类型的属性值转换为所需的类型实体
- gnome - 我的应用程序如何从 Flatpak 分配系统中的键盘快捷键?
- ruby-on-rails - 我无法使用 rails s 命令运行 Rails 服务器。它会抛出 NoMethodError
- python - IndexingError: Too many indexers ,在创建绘图时出现
- angular - 如何在使用异步 ngOnInit 时/之后更新视图?
- r - 使用 R 进行实时音频分析
- java - 如何引用我在 JScrollPane 中滚动的距离?