RE: [PHP] REGEX: grouping of alternative patterns



On 30 October 2007 11:07, Stijn Verholen wrote:

Hey list,

I'm having problems with grouped alternative patterns.
The regex I would like to use, is the following:

/\s*(`?.+`?)\s*int\s*(\(([0-9]+)\))?\s*(unsigned)?\s*(((auto_i
ncrement)?\s*(primary\s*key)?)|((not\s*null)?\s*(default\s*(`.
*`|[0-9]*)?)?))\s*/i

Since all the parts beyond the id and datatype are optional, I don't see how this can ever not match. Please define more accurately what you mean by "doesn't match".

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 812 4730 Fax: +44 113 812 3211


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
.