2
Contributors
7
Replies
9
Views
5 Years
Discussion Span
Last Post by pritaeas
0

Something like:

preg_replace('%(^++ b.*?)(++ c)%', '$2', $yourfile);

but you'll have to do some test to see if it is correct.

Edited by pritaeas: n/a

0

Something like:

preg_replace('%(^++ b.*?)(++ c)%', '$2', $yourfile);

but you'll have to do some test to see if it is correct.

Thankyou for your reply. But in my above paragraph , "b" is the only known variable. a,c and others are unknown.(changable).

What is the best solution for this problem? Please help me.

0

Just remove the c from the pattern. As long as the line will start with ++ it will still work.

Even if i remove c, preg_replace function replace the following text including ++.

++ b
yyy
yyyy
yyyyy

++

i only need to delete

++ b
yyy
yyyy
yyyyy

Any Solutions please?

1

My test show you should use this:

$result = preg_replace('/(^\+\+ b.*?)(^\+\+)/sm', '${2}', $subject);
Votes + Comments
Very useful
0

My test show you should use this:

$result = preg_replace('/(^\+\+ b.*?)(^\+\+)/sm', '${2}', $subject);

thanks for your reply. what this syntax "${2}" tells ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.