Home > database >  How can I extract text between nth instance of forward slashes?
How can I extract text between nth instance of forward slashes?

Time:07-03

I want to extract all words between "products" and / (forward slash) or period (.)

In the example below, I want to extract "pants" and "shoes"

www.site.com/products/pants.html

www.site.com/products/shoes/sneakers.html

The closest I came was this (?<=/products/).*($.|/) How do I include "." OR "/"

CodePudding user response:

If nth occurance is e.g. two:

^(?:[^\/]*\/){2}([^.\/] )

See this demo at regex101

  • Related