Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
简单正则表达式帮助php_Php_Regex - Fatal编程技术网

简单正则表达式帮助php

简单正则表达式帮助php,php,regex,Php,Regex,我有这样一个字符串: MyText (1,151) 我希望使用regex只获取()中的值,在本例中仅为:1151 我知道这很简单,但我不擅长正则表达式 谢谢 这将起作用: if (preg_match($str, '/\(([^)]*)\)/', $matches)) { $content = $matches[1]; } 几乎相同的问题。其中有一些解决方案对您有效;) 获取expresso以构建和学习regexesI,我建议您也看看相关的问题。对如此琐碎的事情使用正则表达式通常是过

我有这样一个字符串:

MyText (1,151)
我希望使用regex只获取()中的值,在本例中仅为:1151

我知道这很简单,但我不擅长正则表达式

谢谢

这将起作用:

if (preg_match($str, '/\(([^)]*)\)/', $matches))
{
    $content = $matches[1];
}

几乎相同的问题。其中有一些解决方案对您有效;)

获取expresso以构建和学习regexesI,我建议您也看看相关的问题。对如此琐碎的事情使用正则表达式通常是过分的。