How to convert a pseudo url to regex efficiently in PHP?
- by user198729
url: articles/:id/:title
id: \d+
The above should result in :
articles/(?P<id>\d+)/(?P<title>.*)
It's used to in many mvc frameworks for routing.
How to do it in fewest lines?
A short demo is the best!