我想选择特定子字符串之前和之后的所有文本,我使用以下表达式来做到这一点,但它没有选择所有需要的文本:
/^(?:(?!\<\?php echo[\s?](.*?)\;[\s?]\?\>).)*/
例如:
$re = '/^(?:(?!\<\?php echo[\s?](.*?)\;[\s?]\?\>).)*/';
$str = 'customFields[<?php echo $field["id"]; ?>][type]';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
它只会选择这部分customFields[,而预期结果应该是customFields[和][type]
小怪兽爱吃肉
蝴蝶不菲