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 3 2065
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 ?
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 ?
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. | This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: fartsniff |
last post by:
hello all,
here is a preg_match routine that i am using. basically, $image is set in
some
code above, and it can be either st-1.gif or sb-1.gif (actually it randomly
picks
them from about 100...
|
by: Han |
last post by:
I'm wondering if someone can explain why the following works with
preg_match_all, but not preg_match:
$html = "product=3456789&"
preg_match_all ("|product=(\d{5,10})&|i", $html, $out);
$out...
|
by: stoppal |
last post by:
need to extract all text between the following strings, but not
include the strings.
"<!-- #BeginEditable "Title name" -->"
"<p align="center">#### </p>"
I am using preg_match(????, $s,...
|
by: awebguynow |
last post by:
I ran across this code, and it kind of made me nervous: (as an email
validator)
if ( !preg_match("/.*\@.*\..*/", $_POST) | preg_match("/(\)/",
$_POST) )
1) from bitwise experience with "C",...
|
by: squash |
last post by:
I have a string equal to 'www/' that I want to use in a preg_match. Php
keeps giving me the warning:
Warning: preg_match(): Unknown modifier '/'
How can I escape the string so the / in www/ is...
| |
by: Mark Woodward |
last post by:
Hi all,
I'm trying to validate text in a HTML input field.
How do I *allow* a single quote?
// catch any nasty characters (eg !@#$%^&*()/\)
$match = '/^+$/';
$valid_srch = preg_match($match,...
|
by: mantrid |
last post by:
Hello
Found this piece of code using preg_match to check file types during upload
of files.
$allowed_file_types = "(jpg|jpeg|gif|bmp|png)";
preg_match("/\." . $allowed_file_types . "$/i",...
|
by: Synapse Syndrome |
last post by:
Hi
I've been given what I am told is a PHP script to be used on my server. I
do not know any PHP.
I am trying to use a feature of a program called ArchiCAD. This feauture
allows CAD drawing...
|
by: JanDoggen |
last post by:
function vldLicense($lic)
{
echo "called with lic: ". $lic . "<br>";
echo preg_match('', $lic) . "<br>";
if (preg_match('{4}-{4}-{4}-{4}', $lic) == 0) return false;
return true;
}
gives me:
|
by: Thomas Mlynarczyk |
last post by:
Hello,
I want to split a given string into tokens which are defined by regexes:
// example tokens - a bit more complex in real
$tokens = array(
'NUMBER' ='~^\d+~',
'NAME' ='~^+~',
'ANY' ...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |