I am looping through all the links on a page and matching their href values against the following pattern:
([^/]+)/([0-9]+)/([^/]+)
Problem is there are 2 types of link formats on the page:
1. /video/123/slug
2. /video/123
Number 1. gets captured fine with the above regex but the 2nd fails. I want to make the third piece of the regex (the slug) optional so that both link formats return true when matched agains the regex. How to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…