Reputation: 1
I wonder how can I improve my expresssion to check everything in one expression instead of create a lot of rules.
here is my expressions
/from-([^/]+)-([^/]+)/
/from-([^/]+)-([^/]+-[^/]+)/
/from-([^/]+)-([^/]+-[^/]+-[^/]+)/
I would like check phrase: from-Country-city or from-Country-city-city or from-Country-city-city-city
Upvotes: 0
Views: 63
Reputation: 469
I believe that this expression satisfies your requirements:
from-(\w+)-([\w-]+)
Here is a live example/demomstration: https://regex101.com/r/gF0fS2/1
The meaning of the expression:
from-
(\w+)
-
([\w-]+)
For more information on regular expressions, please see these websites:
Upvotes: 1