【发布时间】:2023-03-31 23:40:01
【问题描述】:
我似乎找不到捕获并返回正则表达式字符串的函数。
$string = "hello123!";
$string = regexfunction($string, "/([0-9]*)/");
echo $string;
打印
123
【问题讨论】:
我似乎找不到捕获并返回正则表达式字符串的函数。
$string = "hello123!";
$string = regexfunction($string, "/([0-9]*)/");
echo $string;
打印
123
【问题讨论】:
您想为此使用preg_match,尽管语法会略有不同:
$string = "hello123!";
preg_match("/[0-9]+/", $string, $matches);
print $matches[0]; // 123
【讨论】: