English 中文(简体)
更正 preg_ 替换格式
原标题:Correct preg_replace format

替换 (xxxxxxx) 之间的所有(包括括号) 的正确预置替换格式是什么。 示例有字符串( 不长) 链接 : AAAABBBB( AAABBBBB)( AAAABBBB)( AAABBBB)( AAAABBBB)( AAAABBBBB), 而我想要的就是 AAAABBBB( AAABBBBB) 。 我需要使用预置替换作为字符串, 并更改字符串长度 。

谢谢 谢谢

最佳回答

不知道我是否理解你的问题是否正确, 但这应该会将括号中的字符串还回去。

$string = "CCCCC (AAAAABBBBB)";
return preg_replace("(.+(|))","",$string);

此正则将基本上查找后面的字符串( 和单数), 代之以“ ” 。

问题回答

暂无回答




相关问题
RegEx, preg_replace_callback Question PHP

This is what I ve got for for my RegEx, I was wondering if this is the best way. I want to be able to find something similar regardless of the spacing between Identifiers and not be case sensitive. ...

Convert all br tags into one universal <br />

need a simple preg_replace to convert all <br> <br/> and all possible br combinations to <br />. This needs to work in order so i can process a string ie: $output = preg_replace( ,...

What is the business best practice on validating filename?

I have a "dilema" and wonder what is business best practice. I m using Uploadify to upload images. Now I need to validate the filename before saving the file. I ve looked at different solutions, but ...

PHP not change color in quotes

I want to change the color of text inside single quotes, but i have also want to change the color of parenthasis as long as they arent in quotes. this is what i have but its not working as planned. "/...

热门标签