[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Nifty enhancement to [query ...]
On Wed, 16 Jan 2002, Jason Kohles wrote:
> Of course you should also escape the period in this regexp, or else you will
> end up only getting rid of newlines. =)
That's not correct. A period inside a character group [...] is just a
period.
> And just to be safe you should escape the dash, to ensure that perl doesn't
> find a way to turn it into a range, either that or make sure it's the first
> character in the group.
>
> $CGI->{keywords} =~ s/[^\s\w\.\-#%]//g;
The dash was in the wrong place, that's true. The simplest way is:
s/[^\s\w.#%-]//g;
Jon