Re: [PHP] REGEX: grouping of alternative patterns [SOLVED]
- From: stijn@xxxxxxxxxxxxx (Stijn Verholen)
- Date: Tue, 30 Oct 2007 14:33:35 +0100
Robin Vickery schreef:
[snip]
Because each of your subpatterns can match an empty string, the
lefthand subpattern always matches and the righthand subpattern might
as well not be there.
Indeed they do, i did not realise that.
The simplest solution, if you don't want to completely rethink yourBecause this is for a proof-of-concept application that will only be used by me for the time being, and because I always give a default value when specifying 'not null', I'm going to use the following, and think about a more general solution if and when the need arises.
regexp might be to replace \s with [[:space:]], remove the delimiters
and the i modifier and just use eregi(). like so:
This matches both my cases:
/\s*(`?.+`?)\s*int\s*(\(([0-9]+)\))?\s*(unsigned)?\s*(((not\s*null)\s*(default\s*(`.*`|[0-9]*)?))|((auto_increment)?\s*(primary\s*key)?))\s*/i
[snip]
-robin
Thanks for your insights, Robin !
Greetz,
Stijn
.
- References:
- REGEX: grouping of alternative patterns
- From: Stijn Verholen
- Re: [PHP] REGEX: grouping of alternative patterns
- From: "Robin Vickery"
- REGEX: grouping of alternative patterns
- Prev by Date: Re: [PHP] moving over to php 5
- Next by Date: Re: [PHP] moving over to php 5
- Previous by thread: Re: [PHP] REGEX: grouping of alternative patterns
- Next by thread: RE: [PHP] REGEX: grouping of alternative patterns
- Index(es):