I’ve got a pretty long regex to match an entry in a list I’m processing. The list should be one or more of these entries, comma-separated. Consider a regex:
([abc]+|[123]+)
for the entry. To match my comma-separated list, I’m matching against something like this:
([abc]+|[123]+)(,([abc]+|[123]+))*
(It looks especially foolish with my nasty regex instead of the short one I used here for the example)
I feel there must be a better way than having two copies of the entry — once for the first entry, again for and follow comma/entry pairs.
Something like this perhaps:
Broke down it’s:
PHP Demo (Was simplest way to demonstrate)