首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

求php从一段字符串中截取指定内容的正则表达式代码解决方案

2012-06-05 
求php从一段字符串中截取指定内容的正则表达式代码字符串是这样的 fhghfghdfpostm|a:2:{i:5i:0i:2i:0}

求php从一段字符串中截取指定内容的正则表达式代码
字符串是这样的 fhghfghdfpostm|a:2:{i:5;i:0;i:2;i:0;}dsfdsdfsd

也可能是fhghfsdfsdfgdfgdfgdfgghdfpostm|a:2:{i:5;i:0;i:2;i:0;i:0;i:0;i:0;}dsfdsdfsdsdfsdfgsdgsdg

我想要截取其中的 postm|a:2:{i:5;i:0;i:2;i:0;}或者postm|a:2:{i:5;i:0;i:2;i:0;i:0;i:0;i:0;} 但是这个字符串的长度不固定 求代码

[解决办法]

PHP code
$s = 'fhghfsdfsdfgdfgdfgdfgghdfpostm|a:2:{i:5;i:0;i:2;i:0;i:0;i:0;i:0;}dsfdsdfsdsdfsdfgsdgsdg';echo preg_replace('/.*(postm.+\}).*/', '$1', $s); 

热点排行