Greetings Francis, One of the coolest things 'bout perl is context. Things mean different things in different places. My regex is still developing but I think here's what's going on... the ^ means beginning of the string in regex, unless you put it in [^ ]. Then it means Not... So your matching is really saying if the string starts with anything but a space. Might try " /^\s?$String\s?$/i " where we look at either the beginning of the line (notice context) followed by 0 or 1 spaces, your string and either a space or the end of line.(case insensitive) I think this'll replace the entire if block: &OutputSearch if $Handle=~/^\s?$String\s?$/i; Good luck, 'member I'm still working through my own regex learning curve, so I could be hallucinating. JMK > >>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 > > > John-Michael Keyes - jk@infohiway.com http://www.infohiway.com