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
Try the following:
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).