Thank you for the tips and the help.  I really appriciate it.  You
have given me something that I can use to learn regular expressions.

Thanks,
Robert


On Fri, 15 Oct 2004 11:04:57 +0800, Jason Wong <[EMAIL PROTECTED]> wrote:
> On Friday 15 October 2004 10:35, Robet Carson wrote:
> 
> 
> > need a regexp to get the contents of this marker or one very simular:
> >
> > {!STATISTICS:starbucks!}
> >
> > what I am looking for is to get the "STATISTICS" and "starbucks" into
> > an array() if possible.  I believe with the correct regexp this can be
> > accomplished using preg_split() or by getting the contents of the
> > marker and explode()'ing them.  also i am looking to grab several
> > strings for a marker like this, for instance.
> >
> > {!STASTISTICS:starbucks:blended:chocolate!}
> >
> > Also if someone could direct me to a site that explains how to use and
> > create regexp in a small minded manor since I have been unable to
> > grasp the concepts.
> 
> A few tips for starting out with regex:
> 
> 1) use PCRE, they are faster and ultimately more useful than the POSIX variety
> 2) Build up your regex step-by-step and test it at each step to see what is
> being matched and what isn't (and why it isn't)
> 3) Use parentheses () to enclose the bits you want to 'capture' (extract).
> 4) Practice
> 5) More practice
> 
> So for your first example, as a first draft you can just capture everything
> between the begin marker and the end marker:
> 
>   $doo = '{!STATISTICS:starbucks!}';
>   preg_match('/\{!(.*)!\}/', $doo, $match)
> 
> $match[1] now contains: STATISTICS:starbucks
> 
> You can explode() it to get the constituent parts.
> 
> Or you can refine your regex:
> 
>   preg_match('/\{!(.*):(.*)!\}/', $doo, $match)
> 
> So basically your first draft would match a large chunk of stuff, your
> successive drafts would fine-tune it until eventually you're matching exactly
> what you need.
> 
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
> ------------------------------------------
> Search the list archives before you post
> http://marc.theaimsgroup.com/?l=php-general
> ------------------------------------------
> /*
> Today you'll start getting heavy metal radio on your dentures.
> */
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
R. Carson

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GIT d s+:+ a- C++++$ ULL+++>++++$ P+>++++ L+++>+++++$ !E- W N+ !o K-?
!w--- !O !M !V PS+ PE+ Y+ PGP+ !t !5 !X R+ !tv b++ !DI !D G++ e+ h----
r+++ y++++
------END GEEK CODE BLOCK------

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to