TiVo Community Forum Archive 1

TiVo Community Forum Archive 1 (http://archive.tivocommunity.com/tivo-vb/index.php)
- TiVo UK (http://archive.tivocommunity.com/tivo-vb/forumdisplay.php?forumid=14)
-- Using Digiguide to set manual recordings via TiVo web (http://archive.tivocommunity.com/tivo-vb/showthread.php?threadid=141584)


Posted by pgogborn on 11-17-2003 11:45 PM:

quote:
Originally posted by sanderton
I'm not 100% sure as I tend to program these things by trial and error rather than deep understanding, but if I read your code frangment right and string match works the way I think it does then:

BBC 2 Crime Afternoon: Harry's Game
would indeed match
HARRYS GAME (1982)

but

HARRYS GAME (1982)
would not match
BBC 2 Crime Afternoon: Harry's Game



Perhaps I am still at cross purposes with you, but the problem as originally stated was that:
SMarteenies instead of Smarteenies
Enterprise instead of Star Trek: Enterprise
was making it difficult to compare the strings.

I therefore used
code:
if {[string match -nocase

to do a case insensitive comparison. This takes care of the SMarteenies / Smarteenies problem.

However, before the case insensitive comparison was made, I used
code:
regsub -all {^.+:|

to remove from the string everything that preceded the [final] colon symbol. This takes care of the Enterprise / Star Trek: Enterprise mismatch.


For good measure I used
code:
[^a-zA-Z

to remove numbers, blanks, punctuation marks etc as these non-critical characters can be entered differently depending on who is typing the title into the database.

Like you I use a trial and error method - I think a problem of understanding the code could be that the claret ^ has two different meanings according to context.

In
code:
{^.+:|
it anchors a search patern to the begining of a string.

In
code:
[^a-zA-Z
it means 'search for the inverse [opposite] of the specified pattern'.

Hmm! so much for this Perl / Tcl comparison that claims "Tcl is much simpler and easier to learn than Perl... the Perl language is riddled with special cases and idioms" >
http://www.mcs.sdsmt.edu/~mcgough/tcltk/tcltk.html

For a step-by-step breakdown of the sting comparison you can view the transformations using this code >

set Tribune_title "BBC 2 Crime Afternoon: Harry's Game"
set DigiGuide_title "HARRYS GAME (1982)"

regsub -all {^.+:|[^a-zA-Z]} $Tribune_title "" compacted_Tribune_title
regsub -all {^.+:|[^a-zA-Z]} $DigiGuide_title "" compacted_DigiGuide_title

string match -nocase $compacted_Tribune_title $compacted_DigiGuide_title

if { [string match -nocase $compacted_Tribune_title $compacted_DigiGuide_title] } {
puts "In a case insensitive comparison, compacted titles match:\n$compacted_Tribune_title (\$compacted_Tribune_title)\n$compacted_DigiGuide_title
(\$compacted_DigiGuide_title)\n"
puts "Original uncompacted titles were:\n$Tribune_title (\$Tribune_title)\n$DigiGuide_title (\$DigiGuide_title)"
} else {puts "In a case insensitive comparison, compacted titles do NOT match:\n$compacted_Tribune_title (\$compacted_Tribune_title)\n$compacted_DigiGuide_title
(\$compacted_DigiGuide_title)\n"
puts "Original uncompacted titles were:\n$Tribune_title (\$Tribune_title)\n$DigiGuide_title (\$DigiGuide_title)" }


All times are GMT. The time now is 09:48 AM.

Powered by: vBulletin Version 2.2.8
Copyright © Jelsoft Enterprises Limited 2000, 2001.
(C)opyright - All Rights Reserved. No information may be posted elsewhere without written permission.
TiVoŽ is a registered trademark of TiVo Inc. This site is not affiliated with TiVo Inc.