Liquid Remove / Replace Specific Strings Between "[" "]"

Solved
Highlighted
New Member
2 0 0

Hi there, I'm looking to create a variable string for my structured data so that we can remove certain characters out of our product title, for example:

  • [BACKORDER ETA August 10th] BlackVue DR900S-2CH IR 4K Dash Cam
  • [LIMITED QUANTITY] BlackVue DR750S-2CH IR + DR750S-1CH + BlackVue B-124X + Bonus 1 Year Warranty
  • [BACKORDER ETA July 31st] VIOFO A129 Pro Duo 4K 2-Channel Dash Cam with GPS

I would like to create a piece of code for my schema so that it removes the [...] part out of the title, so that the titles would be:

  • BlackVue DR900S-2CH IR 4K Dash Cam
  • BlackVue DR750S-2CH IR + DR750S-1CH + BlackVue B-124X + Bonus 1 Year Warranty
  • VIOFO A129 Pro Duo 4K 2-Channel Dash Cam with GPS

Here's what I've got so far, but I know it's not working:

 

"name": "{{ product.title | strip_html | escape }}",

 

I believe I should be replacing the strip_html portion with remove: "[...]", but unsure how to create an array to capture all the characters within.

Thanks for your help!

0 Likes
Highlighted
Shopify Partner
582 69 93

This is an accepted solution.

please try this

{% assign my_array = "[BACKORDER ETA August 10th] BlackVue DR900S-2CH IR 4K Dash Cam" | split: "]" %}

{{ my_array.last }}

 

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution

Skype : lokendra.panwar1
0 Likes
Highlighted
Shopify Partner
2294 117 353

@BlackboxMyCar Propero's got the output solution.

Keep in mind when creating products and putting things like "[BACKORDER ETA August 10th]" in the title that when you rename theme you  ALSO need to edit the product.handle or that incorrect title could stay in search results forever. This isn't an issue if your adding this info after a products been made unless you need that info to also show in search results or be part of the product url(product.handle)

https://help.shopify.com/en/manual/products/add-update-products#edit-a-search-engine-listing-preview

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
0 Likes
Highlighted
New Member
2 0 0

Thanks, it works!

0 Likes