正则的问题(| at [^\ ]+ Port [0-9]+|i)
时间:2011-09-24
来源:互联网
- $host = 'www.example.com';
- echo $_SERVER[(SERVER_SIGNATURE)];
- $_SERVER[(SERVER_SIGNATURE)] = preg_replace((| at [^\ ]+ Port [0-9]+|i), ( at ) . $host . ( Port ) . $port, $_SERVER[(SERVER_SIGNATURE)]);
- echo "The new is ---" . $_SERVER[(SERVER_SIGNATURE)];
Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.10 with Suhosin-Patch Server at www.example.com Port 80
The new is ---Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.10 with Suhosin-Patch Server at www.example.com Port
请问PHP的正则 [^\ ] 可以匹配 www.example.com 吗? why?
作者: andis01 发布时间: 2011-09-24
“请问PHP的正则 [^\ ] 可以匹配 www.example.com 吗? why?”
可以!
测试也证明了:
复制代码
输出:
<address>Apache/2.2.14 (Ubuntu) Server at localhost.com Port 80</address>
The new is ---<address>Apache/2.2.14 (Ubuntu) Serveratwww.example.comPort</address>
可以!
测试也证明了:
- $host = 'www.example.com';
- $port = '';
- echo $_SERVER['SERVER_SIGNATURE'];
- $_SERVER['SERVER_SIGNATURE'] = preg_replace('/ at [^\ ]+ Port [0-9]+/i', 'at'.$host.'Port'.$port,$_SERVER['SERVER_SIGNATURE']);
- echo "The new is ---" . $_SERVER['SERVER_SIGNATURE'];
<address>Apache/2.2.14 (Ubuntu) Server at localhost.com Port 80</address>
The new is ---<address>Apache/2.2.14 (Ubuntu) Serveratwww.example.comPort</address>
作者: ddm 发布时间: 2011-09-24
“请问PHP的正则 [^\ ] 可以匹配 吗? why?”
可以!
测试也证明了:输出:
Apache/2.2.14 (Ubuntu) Serve ...
ddm 发表于 2011-9-24 20:03
可以!
测试也证明了:输出:
Apache/2.2.14 (Ubuntu) Serve ...
ddm 发表于 2011-9-24 20:03
测试我都测试了, 我就想问这是为什么呢?
作者: andis01 发布时间: 2011-09-24

- [^\ ]
除非你不知道这个是什么意思
作者: ddm 发布时间: 2011-09-24
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28