469,272 Members | 1,417 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,272 developers. It's quick & easy.

Please help me with PREG_MATCH

Hi all,

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.

Joe

Jul 17 '05 #1
3 1944
Krakatioison wrote:
Hi all,

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.

Joe


Do you want to echo the literal text: [quote etc] or what's between the
quote tags ?
Jul 17 '05 #2
Hi Pjotr,
I need to echo only the original text between "quote:"
Thanks for trying to help me.
Joe


"Pjotr Wedersteers" <pj***@wedersteers.com> wrote in message
news:41***********************@news.xs4all.nl...
Krakatioison wrote:
Hi all,

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.

Joe


Do you want to echo the literal text: [quote etc] or what's between the
quote tags ?

Jul 17 '05 #3
Krakatioison wrote:
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]
I assumed the number is a hexadecimal number.
Number after "[quote:" is always different and changing its length.
<?php
$text = 'before [quote:1abc08f] middle [/quote:1abc08f] after';

$rx = '/\[quote:([0-9a-fA-f]+)\](.*)\[\/quote:\1\]/';
$text2 = preg_replace($rx, '***\2***', $text);

echo $text, "\n";
echo $text2, "\n";
?>
I need to parse this and display it using different color.
Replace the "***" with whatever you prefer.
Just so, when I display the text, people could figure out where the
quotation starts and ends.


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. |
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by fartsniff | last post: by
2 posts views Thread by Han | last post: by
reply views Thread by awebguynow | last post: by
4 posts views Thread by squash | last post: by
5 posts views Thread by Mark Woodward | last post: by
6 posts views Thread by mantrid | last post: by
9 posts views Thread by Synapse Syndrome | last post: by
8 posts views Thread by Thomas Mlynarczyk | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.