RE: escaping % AND \%



Then if you want all chars to be treated literally, then I presume you
want:
\%
To be translated to:
\\\%
So just adding your $esc to the left part of s/// should do the trick,
right?


-----Original Message-----
From: Bill Moseley [mailto:moseley@xxxxxxxx]
Sent: Friday, June 29, 2007 10:55 AM
To: dbi-users@xxxxxxxx
Subject: Re: escaping % AND \%

On Fri, Jun 29, 2007 at 04:01:25PM +0100, Raf wrote:
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?

No, I don't want to give the user access to the % or _. I'm using

'%' . $user_string . '%'

but I don't want $user_string to have any special characters. If
$user_string includes \ or % or _ I want them to be literal, without
special meaning.



--
Bill Moseley
moseley@xxxxxxxx

.



Relevant Pages

  • Db link creation
    ... I presume most of u guyzz are very familiar with) for creating a DB ... starting with numbers or containing special characters, ... gives an invalid SQL exception as there are many restrictions on schema ...
    (comp.databases.oracle.tools)
  • Regular Expression - String Manipulation in VBA
    ... I am just tiring to validate my controls using RegExp in VBA, ... chars ... They can use these special characters in between the text. ...
    (comp.lang.basic.visual.misc)
  • RegExp - String in VBA
    ... I am just trying to validate my controls using RegExp in VBA, ... chars ... They can use these special characters in between the text. ...
    (microsoft.public.excel.programming)
  • Re: Regular Expression - String Manipulation in VBA
    ... chars (either single char or 'n' chars) ... They can use these special characters in between the text. ... Are you looking for text that contains at least 3 letters of the alphabet and that as long as you ...
    (comp.lang.basic.visual.misc)
  • Where have all the umlauts gone?
    ... Given an array of chars such as ... conversion to string returns in getting ripped of the special characters ...
    (comp.lang.cpp)