You are here:  » Regular Expressions (RegExp) in Filters

Support Forum



Regular Expressions (RegExp) in Filters

Submitted by peterb on Mon, 2012-03-12 16:45 in

Hi David,

I am currently using the suggested pipe format of Regular Expressions in my filters for matching ie:
(infant|infants|baby|babies|toddler|toddlers)

But the problem is if I use words like (shin) I can match products like 'Shin Guards' and 'Shiney Black Helmet' and I would like better control if possible with my RegExp filter strings.

Can you please advise me how to change my global filter 'Drop Record RegExp' so I can include more RegExp strings for better matching.

And if I cannot open up this field to proper RegExp, what is the list of Regular Expressions I can use in these filters currently.

Submitted by support on Mon, 2012-03-12 18:26

Hi Peter,

Each entry in the pipe separated list is essentially an expression in its own right so you can use any valid perl regular expression, so for example to match Shin at the beginning of the field only followed by a space, you could use

^Shin\s

(the \s matches white space)

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by peterb on Mon, 2012-03-12 21:04

Great thanks.

I am trying to use the following RegExp which I validated in an online RegExp validator tool on products that I want to match:
(\bGoggle\b.+\bCase\b)

But it does not work in my global filter. I think it is converting it to:
(\\bGoggle\\b.+\\bCase\\b)

Any ideas why this would not work?

Submitted by support on Tue, 2012-03-13 10:14

Hi Peter,

That sounds like the same magic quotes situation described in this post. With the modification in place, the supurflous slashes will be stripped and the RegExp should work as expected...

Cheers,
David.
--
PriceTapestry.com