Forum Moderators: coopster

Message Too Old, No Replies

PHP REGEXP Help!

Driving me nuts..

         

Jafo

8:45 pm on Feb 19, 2006 (gmt 0)

10+ Year Member



Have some text like so:


<P>
adsfasdfasdfasdfasdffsd
asdfasdf
dsafsdfasdfasdfasdfasdf
asdfasdfasdf
</P>
asdfasdf
fasfdasd
aasdfasdf

I am trying to eliminate the carriage returns between the P tags (only). I have tried just about everything I can think of and am at a loss. Everything I do try does nothing to the text at all.. Any pointers?

ramoneguru

7:02 am on Feb 20, 2006 (gmt 0)

10+ Year Member



1. Read in a line
2. If the first 4 characters match <p> then read in the next line.
3. Get the first 4 characters
4. If the first 4 characters match </p> then stop
Else
5. Use trim() to remove the trailing cf of the line, then concate the line to like a running string or something
GOTO 1

$beginParagraph = "^<[Pp]>^"; //control for part 2 ereg($beginParagraph, $str);
$endParagraph = "^</[Pp]>^"; //control for part 4

I think the logic is accurate, the regular expressions though......I know it won't work if you have it like this:
<p> some text here
ahaha
haha
</p> shahsfs
but if the paragragraph tags are on seperate lines that should do it...Note: I'm not mr regex so if it doesn't work play around with it.
--Nick