I'm trying to use regex_replace in prestashop product_list.tpl. My code is like:
{$product.description|regex_replace:".*(?=Kompatybilny)":""|strip_tags:'UTF-8'}
I'd like it to show $product.destription after "Kompatybilny" word, but it doesn't work and I don't know why. I've tried different regex functions but still the same - variable doesn't show at all.
You may use
{$product.description|regex_replace:"/.*?(?=Kompatybilny)/su":''}
The regex will match
.*?
- any 0+ chars, as few as possible, up to (but excluding from the match) the first occurrence of(?=Kompatybilny)
- the Kompatybilny
substringsu
- s
means .
can match linebreak chars and u
supports Unicode strings.