php preg_replace regex用其参数替换函数类型字符串[关闭]

I've text for example.

a quick brown fox sance("jumps") over a lazy ok("good") dog.

I want to remove sance() from the above string but inside text. so the output will look like

a quick brown fox "jumps" over a lazy ok("good") dog.

i tried too many regex to remove only sance() but have no luck. most of the time it replaces other ok("good") which is not acceptable.

can somebody plz help me?

Try this one:

$string = 'a quick brown fox sance("jumps") over a lazy ok("good") dog.';

echo preg_replace('/sance\((.*?)\)/', '$1', $string);

Output

a quick brown fox "jumps" over a lazy ok("good") dog.
$pattern = "/sance\((\S+)\)/";
$replace = "\1";
$input_lines = 'a quick brown fox sance("jumps") over a lazy ok("good") dog.';

preg_replace($pattern, $replace , $input_lines);

try it