Home > Blockchain >  Extract text between nth instance of forward slashes
Extract text between nth instance of forward slashes

Time:07-02

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 "/"

Thank you

CodePudding user response:

If nth occurance is e.g. two:

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

See this demo at regex101

  • Related