As the title states, I started thinking about how to match, for example, 2 different subpatterns in a regex applied on a string, on the condition that if the content has only numbers it will be assigned the subpattern name <id>
, otherwise (letters or letters + numbers) assigned as <action>
. The context is a PHP router class I'm writting out.
This is a portion of the condition used to match an action containing words :
(?P<action>[\w]+)
Any ideas?