Re: [PHP] preg_replace pain!

2001-01-18 Thread Christian Reiniger

On Thursday 18 January 2001 07:40, Nicholas Pappas wrote:

 I was hoping someone could help me with this regular expression...

   $pattern = "/\[b\](.*)\[\/b\]/Ui";
 $message = preg_replace($pattern, "B\\1/B", $message);

   The above works for:
   [b]bold text[/b]

   But does not work for:
   [b]bold text
 w/ newline[/b]

add a "s" modifier to the expression and

=

$pattern = "/\[b\](.*)\[\/b\]/Uis";

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

"use the source, luke." (obi-wan gnuobi)

--
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]




Re: [PHP] preg_replace pain!

2001-01-18 Thread Shaun Thomas

On Thu, 18 Jan 2001, Christian Reiniger wrote:

 On Thursday 18 January 2001 07:40, Nicholas Pappas wrote:
 
  I was hoping someone could help me with this regular expression...
 
  $pattern = "/\[b\](.*)\[\/b\]/Ui";
  $message = preg_replace($pattern, "B\\1/B", $message);
 
  The above works for:
  [b]bold text[/b]
 
  But does not work for:
  [b]bold text
  w/ newline[/b]
 
 add a "s" modifier to the expression and
 
 =
 
 $pattern = "/\[b\](.*)\[\/b\]/Uis";

That, and:

$pattern = "|\[b\](.*?)\[/b\]|is"

Shorter regex by one character, and you can use it in perl, too.
Remember, U is a tacked on feature, but ? has always been there,
it's your friend.  I used pipes to remove the necessity of escaping
the forward slash.

Cheers!

-- 
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+
| Shaun M. ThomasINN Database Programmer  |
| Phone: (309) 743-0812  Fax  : (309) 743-0830|
| Email: [EMAIL PROTECTED]AIM  : trifthen  |
| Web  : www.townnews.com |
| |
| "Most of our lives are about proving something, either to   |
| "ourselves or to someone else." |
|   -- Anonymous  |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+



-- 
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]




[PHP] preg_replace pain!

2001-01-17 Thread Nicholas Pappas

I was hoping someone could help me with this regular expression...

$pattern = "/\[b\](.*)\[\/b\]/Ui";
$message = preg_replace($pattern, "B\\1/B", $message);

The above works for:
[b]bold text[/b]

But does not work for:
[b]bold text
w/ newline[/b]

Can anyone help me sort this little issue out?

Many thanks!!

Nick


-- 
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]




RE: [PHP] preg_replace pain!

2001-01-17 Thread Maxim Maletsky


 maybe :  $pattern = "/\[b\]([.\n]*)\[\/b\]/Ui";.

have you tried it succesfully?
P.S: I am not sure that \n in preg is a newline, you could also try this:

$pattern = "/\[b\]([.".chr(10).chr(13)."]*)\[\/b\]/Ui";.

one of these ...

Cheers,
Maxim Maletsky

-Original Message-
From: Nicholas Pappas [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 18, 2001 3:41 PM
To: [EMAIL PROTECTED]
Subject: [PHP] preg_replace pain!


I was hoping someone could help me with this regular expression...

$pattern = "/\[b\](.*)\[\/b\]/Ui";
$message = preg_replace($pattern, "B\\1/B", $message);

The above works for:
[b]bold text[/b]

But does not work for:
[b]bold text
w/ newline[/b]

Can anyone help me sort this little issue out?

Many thanks!!

Nick


-- 
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]

-- 
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]