Click to See Complete Forum and Search --> : Escape for search


edatz
05-09-2011, 06:21 AM
Hi, I have a search that I've used for years to go thru my FFDB's and it works fine - for text. I can pick up things like 150k etc., also.

I now need to be able to see results differently. Say like this:

Search for $var and return var

Searching for var by itself works and the $ is ignored.

So I'm thinking escape special characters but retain what is after them

I've tried this, but it doesn't do the trick.

$match =~ s/([\!\&\$\#\@\\])/.*/gi;


Any ideas?

Thanks

edatz
05-09-2011, 03:42 PM
Think I've done this. I renamed the keyword that was parsed, twice, moving the changes to the beginning of the sub routine.
$match = "$in{'keyword'}";
$wtf = "$match";
$wtf =~ s/([\!\&\$\#\@\\])//g;
Then used the $wtf for the results. When I enter test keywords like
#!perl
or
$var
or
@aaa
I get perl, var and aaa. From there I can have other characters escaped so I can get results.

Originally I had hoped to be able to search for code with entities, then realized that not even Google does that, so won't bother. Instead the Google engine escapes the characters, probably similar to here (dunno, just so long as it works).:)