Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1924

Regular expression question

X-Received by 10.66.139.108 with SMTP id qx12mr26641298pab.36.1436540744403; Fri, 10 Jul 2015 08:05:44 -0700 (PDT)
X-Received by 10.140.47.68 with SMTP id l62mr328683qga.42.1436540744122; Fri, 10 Jul 2015 08:05:44 -0700 (PDT)
Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!i4no641221ige.0!news-out.google.com!4ni79932qgh.1!nntp.google.com!z61no122156qge.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.databases.ms-sqlserver
Date Fri, 10 Jul 2015 08:05:43 -0700 (PDT)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=85.115.54.201; posting-account=dELd-gkAAABehNzDMBP4sfQElk2tFztP
NNTP-Posting-Host 85.115.54.201
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <c81001e7-790a-4f44-9279-48acd08a8392@googlegroups.com> (permalink)
Subject Regular expression question
From rja.carnegie@gmail.com
Injection-Date Fri, 10 Jul 2015 15:05:44 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.databases.ms-sqlserver:1924

Show key headers only | View raw


SQL Server 2005.  The second and third versions of the 
following statement print 'Yes', which is unexpected. 

The intention is to test whether the first term is 
a compound house "number" such as '1A' or '1-3'.
Either / or \ I thought would perform an "escape" 
in the pattern string, to treat a following special 
character as the literal character, but it seems to 
perform correctly without that, not with.  So this 
test may be not doing what I think it is, at all.
And the question is: uh?  ;-)

IF ( '15' LIKE N'[1-9]%[-A-Z]%'  ) PRINT 'Yes 1' 

IF ( '15' LIKE N'[1-9]%[/-A-Z]%' ) PRINT 'Yes 2'

IF ( '15' LIKE N'[1-9]%[\-A-Z]%' ) PRINT 'Yes 3' 

Back to comp.databases.ms-sqlserver | Previous | NextNext in thread | Find similar


Thread

Regular expression question rja.carnegie@gmail.com - 2015-07-10 08:05 -0700
  Re: Regular expression question Erland Sommarskog <esquel@sommarskog.se> - 2015-07-10 21:54 +0200
    Re: Regular expression question rja.carnegie@gmail.com - 2015-07-18 08:59 -0700

csiph-web