Re: [PHP] Regular Expression to replace pseudo-HTML?

2005-04-21 Thread Philip Hallstrom
I'm hoping someone can help me figure out a regex that will replace
pseudo-HTML codes in a string with desired HTML equivalents. In particular,
I'm trying to implement a message quoting facility, such as when you click
on the 'quote'  button in phpBB.
http://us2.php.net/manual/en/function.preg-replace.php
There's an example part way down the page that's almost exactly what you 
want...

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


[PHP] Regular Expression to replace pseudo-HTML?

2005-04-20 Thread Murray @ PlanetThoughtful
Hi All,

 

I'm hoping someone can help me figure out a regex that will replace
pseudo-HTML codes in a string with desired HTML equivalents. In particular,
I'm trying to implement a message quoting facility, such as when you click
on the 'quote'  button in phpBB.

 

An example of a source string would be:

 



 

[quote="John"]Some quoted text.

 

Some more quoted text.

 

[quote="Mary"]My older comment.[/quote][/quote]

 

My current comments.

 



 

Ideally, I'd like this to become something like:

 



 



John wrote:





Some quoted text.

 

Some more quoted text.



Mary wrote:





My older comment.





 

My current comments.

 



 

Given that pseudo-HTML seems common on bulletin board systems I'd hoped
there'd be a published function available to handle it, but I haven't had
any luck finding one and while I've been able to find a couple of regex
examples (eg http://www.regexlib.com/REDetails.aspx?regexp_id=520) they
appear to be aimed at ASP.NET rather than PHP and my attempts to get them
working in PHP (hampered, admittedly, by my general confusion about regex's)
haven't met with any luck.

 

Truly, any help immensely appreciated!

 

Much warmth,

 

Murray