Reputation: 15329
I have a string:
https://domain.tld/123456/api/v1/projects/45242457-foo-bar.json
And I'm trying to match '45242457-foo-bar' using:
preg_match('~"/projects/(.*).json"~', $url, $matches, PREG_OFFSET_CAPTURE);
This keeps returning zero matches. Why?
Upvotes: 0
Views: 337
Reputation: 219834
You need to escape your period (and a greedy *):
~"/projects/(.*?)\.json"~
Upvotes: 2