How to convert a pseudo url to regex efficiently in PHP?

Posted by user198729 on Stack Overflow See other posts from Stack Overflow or by user198729
Published on 2010-03-11T04:26:30Z Indexed on 2010/03/11 4:55 UTC
Read the original article Hit count: 149

Filed under:
|
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!

© Stack Overflow or respective owner

Related posts about php

Related posts about regex