>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"

You could use preg_replaces, like so:
        $result = preg_replace('/--2c.+-c/', '', $the_extention);
That matches anything between '--2c' and '-2c' and replaces it with ''.

You could also use preg_match, like so:
        preg_match('/^(.+)--2c.+-c$/', $the_extention, $matches);
$matches[1] should contain the substring you need.


>A good "baby steps" tutorial on regex too would be appreciated.

Chapter 7 of Learning Perl is an excellent tutorial and basic reference.
        http://www.oreilly.com/catalog/lperl3/

As usual, the trusty PHP manual also has good information:
        http://www.php.net/manual/en/pcre.pattern.syntax.php

---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca            http://mike.teczno.com/contact.html

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

Reply via email to