Re: escaping % AND \%
- From: rafiq@xxxxxxxxxxxxxxxx (Raf)
- Date: Fri, 29 Jun 2007 16:01:25 +0100 (BST)
Hi Bill,
On Fri, 29 Jun 2007, Bill Moseley wrote:
The docs show this for escaping SQL pattern chars:
$esc = $dbh->get_info( 14 ); # SQL_SEARCH_PATTERN_ESCAPE
$search_pattern =~ s/([_%])/$esc$1/g;
But if $search_pattern is '\%' then you end up with '\\%'.
If you have a user defined search pattern which is \%, then you can assume that user wanted to match against the '%' litteral, right? So \\% is what you'd want, isn't it?
I suppose the easy thing is to s/$esc//g first. What's the approachYeah, but that wouldn't match against your \% litteral, which the user intended - would it?
if the $esc is a valid character for the column data?then you'd match against '\'. $esc - as above, wouldn't you?
R.
.
- Follow-Ups:
- Re: escaping % AND \%
- From: Bill Moseley
- Re: escaping % AND \%
- References:
- escaping % AND \%
- From: Bill Moseley
- escaping % AND \%
- Prev by Date: escaping % AND \%
- Next by Date: Re: escaping % AND \%
- Previous by thread: escaping % AND \%
- Next by thread: Re: escaping % AND \%
- Index(es):