So I have the following regular expression:
https?://(www\.)?flickr\.com/photos/(.+)/?
To match against the following URL:
http://www.flickr.com/photos/username/
How can I stop the final forward slash (/) from being included in the username sub-pattern (.+)?
I have tried:
https?://(www\.)?flickr\.com/photos/(.+?)/?
But then it only matches the first letter of the username.
I added
?:to the first group so it’s not capturing, then used[^/]instead of the dot in the last match. This assures you that everything between “photos/” and the very next “/” is captured.If you need to capture the first
wwwjust use this: