hello i'm trying find regex catch terms in url.
for example, given:
https://stackoverflow.com, catch "stackoverflow"
, given https://stackoverflow.com/questions/ask, catch "stackoverflow", "questions", "ask" , potential terms in between slash character after domain name.
up until managed find following regex cannot repeat catching groups
https?:\/\/(?:www\.)?([\da-z-]*)(?:[\.a-z]*)(?:\/([\da-z]*)\/?)+
do guys have ways resolve issue?? great.
i testet answer of michal m appears not "www." updated it
/(?:\/(?:w{3}\.)?)\k([\w]+)/i
edit: it's not important match "www." placed inside non capturing group won't captured. btw placed case insensitive modifier "www." okay too.
Comments
Post a Comment