Re: Combining 2 preg matches.
- From: "frizzle" <phpfrizzle@xxxxxxxxx>
- Date: 17 Jul 2006 07:11:42 -0700
Chung Leong wrote:
Rik wrote:
It just occured to me that, allthough a wonderfull example:
$regex ='/^(?:[a-z]|[a-z][_\-][a-z])+$/';
...will do just fine.
equally so:
$regex ='/^(?:[a-z]+(?:[_\-][a-z]+))+$/';
Lookahead & -behind are unneccessary in this case, and this keep it simple.
Good point. It doesn't make sense to use assertions when you'll capture
the matches anyway.
Somehow, i believe Rik's solution, gave me problems ...
'/^(?:[a-z0-9]|[a-z0-9][_\-][a-z0-9])+$/'; gave problems.
'/^(?:[a-z0-9]|(?<=[a-z0-9])[-_](?=[a-z0-9]))+$/' didn't.
An example string that gave problems is:
really_a_made_up_string
So i used Chung's option.
Frizzle.
.
- Follow-Ups:
- Re: Combining 2 preg matches.
- From: Rik
- Re: Combining 2 preg matches.
- References:
- Combining 2 preg matches.
- From: frizzle
- Re: Combining 2 preg matches.
- From: Chung Leong
- Re: Combining 2 preg matches.
- From: frizzle
- Re: Combining 2 preg matches.
- From: Rik
- Re: Combining 2 preg matches.
- From: Chung Leong
- Combining 2 preg matches.
- Prev by Date: Re: php_sqlite.dll "Access Denied"
- Next by Date: Re: Update only Xml node (PHP5)
- Previous by thread: Re: Combining 2 preg matches.
- Next by thread: Re: Combining 2 preg matches.
- Index(es):
Relevant Pages
|