[thelist] PHP regex for catching text between "<?php" and "?> "

Jon Haworth jhaworth at witanjardine.co.uk
Mon Jun 11 10:53:47 CDT 2001


Yeah, PHP can do that with the preg_match() function, what I need is the
actual regex itself!

Cheers
Jon


-----Original Message-----
From: martin.p.burns at uk.pwcglobal.com
[mailto:martin.p.burns at uk.pwcglobal.com]
Sent: 11 June 2001 16:39
To: thelist at lists.evolt.org
Subject: Re: [thelist] PHP regex for catching text between "<?php" and
"?>"



Memo from Martin P Burns of PricewaterhouseCoopers

-------------------- Start of message text --------------------

Dunno about PHP, but Perl would be able to return everything before
the found string in the line as $` and everything after it as $'

And of course $1 $2 $3 for 'The first thing found matching the regexp',
'the second thing found' etc

Cheers
Martin





Please respond to thelist at lists.evolt.org

Sent by:  thelist-admin at lists.evolt.org

To:   "'thelist at lists.evolt.org'" <thelist at lists.evolt.org>
cc:


Subject:  [thelist] PHP regex for catching text between "<?php" and "?>"


Hi list,

Here's my current mission: Using PHP, find all occurrences of a string that
don't fall between "<?php" and "?>".

Example: Given the string "hello <?php there ?> world <?php foo ?>",
generate an array with element 0 as "hello" and element 1 as "world".

I'm fairly sure that I need to use preg_match (www.php.net/preg-match) to
return my array, the bit I'm having problems with is forming the regex
properly. Not being much good in this department doesn't help :-)

Any kindly regex gurus feel like demonstrating their wizardry and giving me
a pointer?


**********************************************************************
'The information included in this Email is of a confidential nature and is 
intended only for the addressee. If you are not the intended addressee, 
any disclosure, copying or distribution by you is prohibited and may be 
unlawful. Disclosure to any party other than the addressee, whether 
inadvertent or otherwise is not intended to waive privilege or confidentiality'

**********************************************************************




More information about the thelist mailing list