I'm trying to get a search engine to match whole words but not the whole field. I want the engine to pick up jaguar when the field says jaguar cars, or jaguar parts, and just jaguar of course but this line of code picks up pieces of the words in the field that it's trying to compare the search word with. ex.

you type in seat, but the results are for seattle.

I go into the script and have it do exact matching.

type in seat, I get seat results.

type in jaguar I get jaguar results but it doesn't pick up the fields that say jaguar cars, or jaguar parts.

I don't know if I understood the question correctly, but it seems to me that you have to use /(^| )$one1( |$)/ in the big if statement (same trick for $two2,...). This states that the pattern has to be preceded by either the beginning of the line or a whitespace, and that the pattern has to be followed by a whitespace or the end of the line. If you want to, you can add any character between the brackets, if it's preceded by |