正则表达式如何写?{ordinary|normal|regular|standard}
时间:2011-12-16
来源:互联网
以上用正则表达式写出,花括号中间内容只能是字母,空格,|,主要是查出两边的花括号{};
请问这种表达式怎么写?
作者: dhc_1229 发布时间: 2011-12-16
作者: PhpNewnew 发布时间: 2011-12-16
还有以上
}wired phenomenon in the job{
}……{ 中间内容不能有花括号
这个一段的正则又该怎么写?
作者: dhc_1229 发布时间: 2011-12-16
<?php $str = 'asdfefefefefef{ordinary|normal|regular|standard}'; $patten = '/(\{[ a-z|]+\})/i'; preg_match_all($patten,$str,$matches); print_r($matches);
作者: ohmygirl 发布时间: 2011-12-16
<?php $str = 'very ordinary-looking women{regular|standard}wired phenomenon in the job{market|marketplace}but in most of'; $patten = '/\}([^{]+)\{/i'; preg_match_all($patten,$str,$matches); print_r($matches);
作者: ohmygirl 发布时间: 2011-12-16
$STR = 'very ordinary-looking women{regular|standard}wired phenomenon in the job{market|marketplace}but in most of'; preg_match_all('/\{[a-z\s|]+\}/isU', $STR, $matches); print_r($matches); /** 输出结果: Array ( [0] => Array ( [0] => {regular|standard} [1] => {market|marketplace} ) ) */
作者: yangball 发布时间: 2011-12-16
PHP code
<?php
$str = 'asdfefefefefef{ordinary|normal|regular|standard}';
$patten = '/(\{[ a-z|]+\})/i';
preg_match_all($patten,$str,$matches);
print_r($matches);
为什么输出了两边?
作者: dhc_1229 发布时间: 2011-12-16
引用 3 楼 ohmygirl 的回复:
PHP code
<?php
$str = 'asdfefefefefef{ordinary|normal|regular|standard}';
$patten = '/(\{[ a-z|]+\})/i';
preg_match_all($patten,$str,$matches);
print_r($matches);
为什么输……
不是两遍。
匹配的结果保存在$matches[1]中
作者: ohmygirl 发布时间: 2011-12-16
引用 6 楼 dhc_1229 的回复:
引用 3 楼 ohmygirl 的回复:
PHP code
<?php
$str = 'asdfefefefefef{ordinary|normal|regular|standard}';
$patten = '/(\{[ a-z|]+\})/i';
preg_match_all($patten,$str,$matches);
pr……
那就是对的,有没有学习正则表达式好的资料啊?
作者: dhc_1229 发布时间: 2011-12-16
引用 7 楼 ohmygirl 的回复:
引用 6 楼 dhc_1229 的回复:
引用 3 楼 ohmygirl 的回复:
PHP code
<?php
$str = 'asdfefefefefef{ordinary|normal|regular|standard}';
$patten = '/(\{[ a-z|]+\})/i';
preg_match_all($pa……
个人推荐 精通正则表达式 ,通俗易懂。
作者: ohmygirl 发布时间: 2011-12-16
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28