John Doe
John Doe

Reputation: 67

Regex Replace in Mirasvit Sphinx Search

I have a number of sku's listed on my site. The sku's found are 12 digits long. In my store they are listed on the product detail page as 8 chars.

Mirasvit Search has a function to replace this, however how it's supposed to work is a mystery...

I'm debugging the Sphinx Search Replace function on a an old magento store / client's website: 12 characters replace to 8 if regex matches following style:

/([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9])/

Match Replace (4 characters)

([0-9][0-9][0-9][0-9])$

By

(empty)

I need to replace 166278010201 to 16241702 in order to show matching search results...

I've included the documentation: https://mirasvit.com/doc/extension_searchsphinx/current/ssp/global/long_tail

Upvotes: 1

Views: 130

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627110

You may use

Match Expression - /[0-9]{12}/
Replace Expression - /[0-9]{4}$/
Replace Char - empty

This will find all 12-digit chunks of text and remove the last 4 digits from each match found.

Upvotes: 1

Related Questions