Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Please help me with PREG_MATCH
October 26, 2004, 12:55 pm
rate this thread
I need a help to write a simple preg_match.
Imagine, I've got like 5kb of text where one part of the text always
starts with: [quote:129beec637]
and ends with: [/quote:129beec637]
Number after "[quote:" is always different and changing its length.
I need to parse this and display it using different color.
Just so, when I display the text, people could figure out where the
quotation starts and ends.
Could someone please help me with it?
Thanks a lot. Every help is very appreciated and helps me a lot.
Re: Please help me with PREG_MATCH
I assumed the number is a hexadecimal number.
$text = 'before [quote:1abc08f] middle [/quote:1abc08f] after';
$rx = '/\[quote:([0-9a-fA-f]+)\](.*)\[\/quote:\]/';
$text2 = preg_replace($rx, '******', $text);
echo $text, "\n";
echo $text2, "\n";
Replace the "***" with whatever you prefer.
Happy Coding :-)
USENET would be a better place if everybody read: | to mail me: simply |
http://www.catb.org/~esr/faqs/smart-questions.html | "reply" to this post, |
http://www.netmeister.org/news/learn2quote2.html | *NO* MIME, plain text |
http://www.expita.com/nomime.html | and *NO* attachments. |
- Pjotr Wedersteers
October 26, 2004, 8:22 pm
- » Base MySQL par defaut (plutot que mysql_select_db())
- — Previous thread in » PHP Scripting Forum