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

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

WBOY
Release: 2016-06-06 20:15:50
Original
958 people have browsed it

比如这样一个字符串:

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



</code>
Copy after login
Copy after login

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

回复内容:

比如这样一个字符串:

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



</code>
Copy after login
Copy after login

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

就是怎么粗暴

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

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

echo $a[1];

不知道你要的是里还是外

如果是外面的话

preg_match("/^(.*?)\(/", $s, $a);</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template