0

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?

4
  • 1
    Please come up with what you have done so far. Currently you are just asking for someone others solution without even proving that you know what you are talking about. Commented Aug 28, 2013 at 9:12
  • Can there be nested function calls like: a quick brown fox sance("jumps" + strtolower("FOO") + "123" ) over a lazy ok("good") dog. Commented Aug 28, 2013 at 9:27
  • i tried to many regex to achieve my specific output in function preg_replace('REGEX', '$1', INPUT) but with no luck. However, @Bora's regex worked. Commented Aug 28, 2013 at 9:30
  • @anubhava, no, in my case its not nested function. Commented Aug 28, 2013 at 9:32

2 Answers 2

1

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.
0
0
$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

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.