-1

This should not be that difficult. I thought I had a basic understanding of RegEx, but obviously not.

I simply want want to find all records where the ComputerName field begins with AB or CD.

I am running this in Visual Studio, VB.Net against SQL Server.

I am trying things like: Select ComputerName from TableName where ComputerName like '[AB|CD]%'

I have tried every variation I can think of, but I just can't get it.

Thank you in advance!!

Many different variations using brackets, commas, pipes, carrots, etc.

Ron
  • 9
  • 1
    Possible duplicate: [What is the difference between square brackets and parentheses in a regex](https://stackoverflow.com/questions/9801630/what-is-the-difference-between-square-brackets-and-parentheses-in-a-regex). – Bohemian Feb 10 '23 at 21:08
  • Your regex is looking for computernames that start with a character in the character class consisting of an 'A' or a 'B' or a '|' or a 'C' or a 'D'. – Gary_W Feb 10 '23 at 21:09

1 Answers1

1

Use an alternation:

Select ComputerName
from TableName
where ComputerName like '(AB|CD)%'

Or you can just use non-regex like

Select ComputerName
from TableName
where ComputerName like 'AB%'
or ComputerName like 'CD%'
Bohemian
  • 412,405
  • 93
  • 575
  • 722