Home  >  Article  >  Backend Development  >  正则表达式 - php括号内正则问题?

正则表达式 - php括号内正则问题?

WBOY
WBOYOriginal
2016-06-06 20:15:50906browse

比如这样一个字符串:

<code>sakhdfkjashdkas({"d":"jiji"});



</code>

我想只获取括号被的内容,表达式该怎么写呢?

回复内容:

比如这样一个字符串:

<code>sakhdfkjashdkas({"d":"jiji"});



</code>

我想只获取括号被的内容,表达式该怎么写呢?

就是怎么粗暴

<code>$s = 'sakhdfkjashdkas({"d":"jiji"});';

preg_match("/sakhdfkjashdkas\((.*?)\);/", $s, $a);

echo $a[1];

不知道你要的是里还是外

如果是外面的话

preg_match("/^(.*?)\(/", $s, $a);</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn