Re: Combining 2 preg matches.
- From: "Rik" <luiheidsgoeroe@xxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 17:19:32 +0200
frizzle wrote:
Somehow, i believe Rik's solution, gave me problems ...$regex ='/^(?:[a-z]|[a-z][_\-][a-z])+$/';Good point. It doesn't make sense to use assertions when you'll
...will do just fine.
equally so:
$regex ='/^(?:[a-z]+(?:[_\-][a-z]+))+$/';
Lookahead & -behind are unneccessary in this case, and this keep it
simple.
capture
the matches anyway.
'/^(?:[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
Ah, forgot that in [a-z0-9][_\-][a-z0-9] the character on the right is
already matched, so it won't work as a start for the second _ in _a_....
This one should still be working though:
$regex ='/^(?:[a-z0-9]+(?:[_\-][a-z0-9]+)*)$/';
Grtz,
--
Rik Wasmus
.
- Follow-Ups:
- Re: Combining 2 preg matches.
- From: Chung Leong
- Re: Combining 2 preg matches.
- From: frizzle
- 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
- Re: Combining 2 preg matches.
- From: frizzle
- Combining 2 preg matches.
- Prev by Date: Re: Forced download issue with IE6
- Next by Date: textarea curiousity
- Previous by thread: Re: Combining 2 preg matches.
- Next by thread: Re: Combining 2 preg matches.
- Index(es):
Relevant Pages
|