更新时间:2023-02-23 08:18:42
preg_match()
时,输出变量是必需的,因此我使用速记条件来确定是否匹配,并为回声设置必要的值。(
然后忘记与K
匹配,然后匹配尽可能多的限定字符。$FolderNumber[$Counter] =
转义。d
与[0-9]
相同。编码:(Demo)
$Counter = 0;
$FolderTitle[$Counter] = "This is 1 example (text) with a (number)(01230_12-3)";
echo preg_match("/(K[-d_]+/", $FolderTitle[$Counter], $out) ? $out[0] : 'no match';
输出:
01230_12-3