D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

[LUG] comma separated value string comparisons



What's the best way to compare two strings, each containing comma separated 
values, to see if ANY of the values in the first string match any of the 
values in the second string?

Ideally, I'd like to do this within an existing SQL query, but PHP could be 
done (and therefore Perl as PHP can use perl regular expression pattern 
matching).

As far as SQL goes, I've tried like and locate as well as the new fangled 
match() against() fulltext index mallarkey. They each match some but not all. 
In particular, match() has an annoying habit of ignoring any value that 
consists of less than 4 characters - so none of the common three-letter 
acronyms match! I know it is possible to adjust the server variables to allow 
three letter matches but that affects all databases and requires both 
downtime and root access.

e.g.
$string1 = "PHP, XML, GnuPG, standards, design";
$string2 = "C++, Perl, PHP, networking, security";

So $string1 should give a match with $string2.

There are many strings, no predetermined number of values or 
case-requirements. The match must be as wide as possible - the intention is 
to err towards over matching rather than missing just one possible match.

Ideas?

Am I going to have get into recursive loops of an undeterminable length?

-- 

Neil Williams
=============
http://www.codehelp.co.uk
http://www.dclug.org.uk

http://www.wewantbroadband.co.uk/

Attachment: pgp00026.pgp
Description: signature


Lynx friendly