skip to Main Content

https://store.myshopify.com/products/burton-custom-freestyle-151

https://store.myshopify.com/products/burton-custom-freestyle-151?variant=31722273144379

From the above: I would like to output: burton-custom-freestyle-151

I got the following regex: [^/]*(?=?) but only work for the 2nd link.

2

Answers


  1. Try the following:

    (?<=products/)((?!?|$).)+
    
    Login or Signup to reply.
  2. If you have access to the Shopify store’s template .liquid files, you can just use
    {{ page.title }} or {{ page.handle }} to check for the specific product (docs).

    Or {{ page.id }} that would not change when the user changes the title of product page.

    If you’re scraping web pages from a Python or Node backend, you can also use URL parsers (urlparse and url respectively).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search