[FAQ] REGEX searches and escaping
Serg
sun2 at public.kherson.ua
Tue Mar 22 20:19:41 CST 2005
Hi Jon,
> Hi Serge,
>
> Just to be clear -- I want \A to be a metacharacter!
> It should mean word-begins-with.
Jon, first of all,
\A -- Match only at beginning of string
> If I escape it it should just be the
> characters '\A', which is NOT what I want.
Let you have in REALbasic string as
"\A12345\Z"
To send this to our SQL parser you must ESCAPE this string
str = Valentina.EscapeString( "\A12345\Z" )
// here str will be "\\A12345\\Z"
Our SQL parser reading it will again produce string
"\A12345\Z"
which will be sent to the REGEX engine.
So in your code it must be as
query = ".. WHERE fld REGEX '" + str + "'"
-----------
In the same time note, that if you work in viSQL or Valentina Studio,
Then in the query window you should type escape chars self:
... WHERE fld REGEX '\\A12345\\Z'
So again our SQL parser reading it will produce string
"\A12345\Z"
which will be sent to the REGEX engine.
--
Best regards,
Serge
More information about the Valentina-beta
mailing list