[thelist] pcre regex in php

Frijo Franco frijo.franco at megasoft.com
Tue Sep 23 07:48:28 CDT 2003


I think this will work for you

<?php
$description = "[cn]Clio Gould, Edmund Coxon, Jeremy Morris, Stephen
Morris,Katiedsdsdsd</uyrty\> Hull[/cn]";
preg_match_all ("/(\[([\w]+)[^>]*\])(.*)(\[\/\\2\])/", $description,
$matches);
$intext = implode(",", $matches[3]);
echo $intext;
?>



thanks and regards
frijo


-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org]On Behalf Of
throwaway at gmontague.co.uk
Sent: Tuesday, September 23, 2003 4:33 PM
To: thelist at lists.evolt.org
Subject: [thelist] pcre regex in php


Hi all,
   I seem to be having a brain block with the following regex....

I'm trying to extract all the text between [cn][/cn] 'tags' in a document.
For example,

$description = "[cn]Clio Gould, Edmund Coxon, Jeremy Morris, Stephen Morris,
Katie Hull[/cn]"

$regex = "\[cn\]([^(?:\/[cn\])]){1,}";
preg_match_all("/$regex/", $description, $matches);

Which I expected to work, but what I get is

"Clio Gould, Edmu"

because (I think) the second part of the regex is treating the 'cn' as part
of a set so I'm hitting the 'n' in Edmund and dropping out. I've looked
though the docs about this but I can't seem to correct it. Any help would
be appreciated.

Cheers,
   gav
--
* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !
-------------- next part --------------
This mail has been scanned for viruses by InterScan Viruswall.

Information contained and transmitted by this E-MAIL is proprietary to Megasoft Ltd and is intended for use only by the individual or entity to which it is addressed and may contain information that is privileged, confidential or exempt from disclosure under applicable law.If you received this message in error or are not the intended recipient, you should destroy the e-mail message and any attachments or copies, and you are prohibited from retaining, distributing, disclosing or using any information contained herein. Please inform us of the erroneous delivery by return e-mail to mailadmin at megasoft.com.



More information about the thelist mailing list