我是 PHP 正则表达式的新手。 我怎样才能用几段长的字符串找到第一个括号的内容。
我假设我必须使用 preg_match 函数
最佳答案
preg_match("/^.*?\(([^\)]+)\)/", $search_this_string, $matches, PREG_OFFSET_CAPTURE);
print_r($matches);
这假设您用括号括起来的字符串不包含任何转义的(以某种方式)右括号。
关于php - 简单的正则表达式问题 : How to find the first parentheses and get the content inside it?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1793414/