RE: [PHP] Need regular match help - possibly

2002-07-25 Thread Mike

Hi

 for the first case - using \n, try :
ereg_replace('\n+', '\n\n\n', $str)

This is right, apart from the fact that \n characters will no be parsed 
with single quotes. Try this...

?php
ereg_replace(\n+, \n\n\n, $str);
?

Sorry, just a minor thing.

Mike


-- 
MGS2 Online
http://www.mgs2online.f2s.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Need regular match help - possibly

2001-11-21 Thread Martin Towell

for the first case - using \n, try :
   ereg_replace('\n+', '\n\n\n', $str)

for the second case - using br, try :
   eregi_replace('(br)+', 'br', $str);

Martin

-Original Message-
From: Gaylen Fraley [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 22, 2001 2:56 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Need regular match help - possibly


I need a routine that will allow me to trap multiple br and/or line feed
characters and convert them to a constant number.  As an example, let's say
that you have text that has 10 carriage returns and/or line feeds.  I want
to limit this to 3.  So, I need to be able to parse the line to detect the
multiple control characters and convert the string to 3.  So if the string
looked something like:

This is \n\n\n\n\n\n\n\n\n\n a test.

I would want it converted to

This is \n\n\n a test.


Conceivably, it could be

This is brbrbrbrbr a test.

I would want it converted to

This is brbrbr a test.


I know I could write a do/while loop, but I was wondering if there is a way
using eregi_replace or something along that line?

Thanks!



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]