Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 regular expression equivalent of....

Author  Topic 

Sitka
Aged Yak Warrior

571 Posts

Posted - 2005-02-24 : 15:59:06
A string must begin with A or B or C

....col1 LIKE 'A%' OR col1 LIKE 'B%' OR col1 LIKE 'C%'



I wish someone would start an Official XML Rant Thread.

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2005-02-24 : 16:29:30
This should also work

col1 LIKE '[ABC]%'

Dustin Michaels
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2005-02-24 : 22:03:15
Thanks, I'll try it.

Is % part of the .NET regular expression library?

I wish someone would start an Official XML Rant Thread.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-02-24 : 22:05:15
Nope, the equivalent RE for "%" would be /.*/
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2005-02-25 : 08:04:48
This is SOOOOO difficult.
I was hoping to learn something but
it ain't going well and I don't think the genaeralized
nature of the original post helped

ASP.NET Regular expression Validator

Validate entry in text box
enrty begins with
'A' OR 'a' OR 'B' OR 'b' OR 'C' OR 'c'
folowed by an indetermine string
valid entries are
A123f, A12f34, a12f345, a123fff, B123 ........ c12

so I was thinking in it's most obvious form
^A/.*/|^a/.*/|^B/.*/|^b/.*/|^C/.*|^c/.*/

maybe as a first step
^[AaBbCc] <x>
where <x> is anything
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-02-25 : 08:34:15
This should work:

/^[A-Ca-c].*/

...or...

/^[AaBbCc].*/
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2005-02-25 : 08:40:25
JYNX.......robvolk haha

hey what are your forward slashes?


progress

went here http://regexlib.com/Default.aspx
searched on 'begins with'
^[AaBbCc].*$


but . means any character
does .* mean ............................ to infinity ?
$ means I guess as in "someplace before infinity"
building on
^[AaBbCc] <need to say folowed by> [0-9]+[0-9]*$


I wish someone would start an Official XML Rant Thread.
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2005-02-25 : 09:02:02
think I got it

^[AaBbCc][1-9]+[0-9]*$

in English, a text string equal to the set of natural numbers
without preceeding zeros that begins with A,a,B,b,C,c

life lesson here, Thanks robvolk

I wish someone would start an Official XML Rant Thread.
Go to Top of Page

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2005-02-25 : 10:02:47
Oops I thought you wanted to do a regular expression thing in T-SQL.

Dustin Michaels
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2005-02-25 : 11:58:51
My fault Dustin.. Thanks for the help.
Sometimes it's just the isolation that gets
to me any way. Any reply is welcome.

I call this the "There are two black phones" syndrome.
Yeah, so what, who cares about the phones? "Exactly."

That's why my original post was poorly defined.
Needed to contemplate the phones.

I wish someone would start an Official XML Rant Thread.
Go to Top of Page
   

- Advertisement -