RE: [PHP] Regex help
| From: | Ryan A | Date: | Mon, 15 Mar 2004 17:34:07 +0000 |
| Subject: | RE: [PHP] Regex help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-180481@lists.php.net to get a copy of this message | ||
Hey,
Thanks guys.
I did search on google first for a tutorial, problem is with something as
widely used as regular expressions
there are LOTS of results...I felt it would be better to ask if anyone has a
favourite..
ie:
if you learnt it off the web and not via the manual.
The last time I had this problem was with cookies and sessions, I found the
links I got from the people
on this list much better than the examples in the manual...after learning
from the web I did go back to the
manual and understood thing much better.
Cheers,
-Ryan
On 3/15/2004 6:18:38 PM, Chris W. Parker (cparker@swatgear.com) wrote:
> Ryan A <mailto:ryan@coinpass.com>
> on Monday, March 15, 2004 9:07 AM said:
>
> > I know this is pretty easy to do but I am horrorable at working with
> > regular expressions and was wondering if anybody might take a min to
> > help please.
>
> in that case you should get the regex coach (easy to find via google).
> it's great!
>
> > I will have a variable: $the_extention
> > which will have a value like: 98797-234234--2c-something-2c
> >
> > How do I take out the part which will always start with "--2c" and
> > will always end with "-2c"
>
> by using () around the part you want to grab.
>
> <?php
>
> $string = "98797-234234--2c-something-2c";
>
> $pattern = "/\d{5}-\d{6}--2c-(.*)-2c/";
>
> preg_match($pattern, $string, $matches);
>
> print_r($matches);
>
> ?>
>
> > A good "baby steps" tutorial on regex too would be appreciated.
>
> there's
> lots of those. google can help you find them. try
> "regular
> expression tutorial" or some variant of that.
>
>
> hth,
> chris.
>
> p.s. i think you want extension not extention. :)
>
> --
> PHP General Mailing List (http://www.php.net/)