RE: [PHP] Regex help

From: Date: Mon, 15 Mar 2004 17:18:38 +0000
Subject: RE: [PHP] Regex help
Groups: php.general 
Request: Send a blank email to php-general+get-180477@lists.php.net to get a copy of this message
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. :)

« previous php.general (#180477) next »