Easy Hack to REGEXP

eyecon - October 31, 2007 - 16:42
Project:News Page
Version:5.x-1.1
Component:Code
Category:feature request
Priority:minor
Assigned:Unassigned
Status:postponed
Description

This was a very easy hack to use regular expressions (note that MySQL does not fully support PCRE).

I eliminated the and/not filters (just for simplicity) and made the following changes:

$title_filter[] = "lower(i.title) REGEXP '" . $word . "'";
$content_filter[] = "lower(i.description) REGEXP '" . $word . "'";
$filter_query = implode(" OR ", $title_filter) . ' OR ' . implode(" OR ", $content_filter);

The primary benefits are for word boundaries: [[:<:]]word[[:>:]]
and phrases: [[:<:]]wordone[[:>:]][[:blank:]][[:<:]]wordtwo[[:>:]]

For me, this is MUCH easier and creates more predictable results than futzing with + or -. Aside from the query code change, it requires more available maxlength. Of course, this DOES increase overhead but I am getting exactly what I want and nothing that I don't want in the results.

Is this worth considering as an option with a radio box on creation?

BTW, I am developing a new news/opinion site. I have tried virtually every possible combination of aggregation, feed parsing and filtering module. News Page is by far the best solution. Thanks for the great work.

#1

Robert Castelo - April 9, 2009 - 00:43
Status:active» postponed

Sorry eyecon, that would make it way to difficult for the average user to use.

Also REGEX is significantly slower.

I'll mark it as postponed because it wouldn't be very difficult to have it as an optional format to switch to with a "Use REGEX" checkbox, so maybe in the Drupal 6 version ;-)

 
 

Drupal is a registered trademark of Dries Buytaert.