Regex, PHP: assigning matches to an array after inserting expanded words -
regex, php: assigning matches array after inserting expanded words in system matches user input against regex pattern allow pattern contain "concept words" marked twiddle (~). e.g. can define ~service-type '"oil change" rotation brake "tune up"' , ~day 'monday tuesday wednesday thursday friday' i can have pre-regex like: .*get.*~service-type.*~day which preprocessing gets expanded to: /.*get.*(oil change|rotation|brake|tune up).*(monday|tuesday|wednesday|thursday|friday)/i so match sentence like: "i'd oil change on wednesday." this gives me nice $matches array looks this: array 0 => string 'i'd oil change on wednesday' (length=42) 1 => string 'oil change' (length=10) 2 => string 'wednesday' (length=9) the difficulty arises possible or necessary regex contains other (...) patterns. in example wouldn't need it, shows point: (.*)(get).*~service-type(.*)~day...