Page 1 of 1

Removing a paragraph

Posted: Thu Nov 25, 2010 10:35 am
by mklynx
Hi all

I am having a problem. I do not have any code to show you for this problem because everything i tried did not work.
My problem is the following. I have a string with a lot of text in it. I do not know what text is in it. I receive it dynamically.
I do know it is build up in paragraphs that are separated with <br/>. The problem is that i do not need all paragraphs.
I need to remove the paragraphs where there are reverences to web sites. like HTTP://www.bla.tv.

I know how to do it in a language that most of you will not know and that is TACL.
You search for the string (http...) get the position of that.
Then you look for the first occurrence of <br/> before the position and look for the first occurrence of <br/> after the position.
Then you delete the part between the two positions you got.

But i do not have enough PHP experience to get this done.
I can get the position of the first search (http...) but then i am stuck how to get the second and third position.

Marcel Koert

Re: Removing a paragraph

Posted: Thu Nov 25, 2010 11:38 am
by josh
strpos is the PHP equivalent for finding the positions of text. But I'd recommend regular expressions language (which can be used with the PHP function preg_replace)