문제

Currently i am using the following code to modify content between {| and |} using a custom function parse_table

$output = preg_replace_callback("({\|(.*?)\|})is", function($m) {return parse_table($m[1]);}, $input);

Now i want to modify it such that the pattern can exclude a certain substring, such as abcde. What could be done to achieve this?

Thank you very much.

도움이 되었습니까?

해결책

You can put it in your regex:

"({\|(?!abcde)(.*?)\|})is"

However, this would get very difficult to read, very fast. Instead, use the callback:

function($m) {
    if( $m[1] == "abcde") return $m[0];
    return parse_table($m[1]);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top