You are here:  » Drop Record if Not RegExp Issue


Drop Record if Not RegExp Issue

Submitted by TWDesigns on Fri, 2016-04-29 17:25 in

David,

I'm not sure what I am doing wrong but I need help!

I am only wanting to import products that have t-shirt or t shirt in the title.

I tried running (t shirt|t-shirt) against the product title field but it didn't work. Then I looked at my feed and one of the categories is T-Shirts so I told it to drop if not in Category and contained T-Shirts and I still get 0 results.

What am I doing wrong!

Submitted by support on Sat, 2016-04-30 07:59

Hi,

The hyphen character should actually already be removed by the "normalisation" of the category field at the top of the import record handler function - see line 199 of includes/admin.php:

$importRecord["category"] = tapestry_normalise($importRecord["category"]);

However, if you have modified this to permit the hyphen character (normally used in place of spaces in search engine friendly URLs) then it would need to be "escaped" (preceded by backslash) in the RegExp as it is used to define a character range, e.g.

(t shirt|t\-shirt)

Regular expressions are case sensitive by default, however you can change this by enclosing the expression within a suitable delimiter character (forward slash is a common choice) and then following the closing delimiter with the "i" modifier e.g.;

/(t shirt|t\-shirt)/i

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by TWDesigns on Sat, 2016-04-30 23:54

That appears to have worked! Thank you David!