[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Newbie: Word matching?




Hello all,


I used regular expressions before in UNIX and vi, but now I'm stuck. I am 
using MacPerl to write CGIs for a web site I'm desiging. I want users to 
be able to search a database of Handles by either partitial or whole word 
match. If the search is partitial there is no problem, but I can't get a 
regular expression to work which *returns word matches*. The script 
compiles OK, but won't return any match even is there are.


Part of the script:

#Find $String in $Handle
if ($values{"Word"} eq "Entire")
{
  if ($Handle =~ /[^ ]$String[\$ ]/) { &OutputSearch(); }
} else {
  if ($Handle =~ /$String/) { &OutputSearch(); }
}

The first regular expression /[^ ]$String[$ ]/ won't work and I have no 
idea why. I even tried to replace the spaces with \s, but still nothing 
happens... I am trying to search for the beginning of a line or a space, 
followed by the string, followed by an end of line or space.

Can someone please tell how the regular expression should be? Or another 
way the achieving the same thing... Any help will be greatly appreciated. 
Forgive me if this question is rather a dumb one, but I can't solve it 
after reading the manual and consulting a Beginners Perl book.

Thanks in advance,


Francis
Francis.VanRoie@khk.be