Need to fix my regex
Posted
by
Misha Zaslavsky
on Stack Overflow
See other posts from Stack Overflow
or by Misha Zaslavsky
Published on 2014-08-23T10:09:44Z
Indexed on
2014/08/23
10:20 UTC
Read the original article
Hit count: 411
I am trying to match a string to a regex
pattern, but have some problems.
My string could have 3 forms:
- [dbo].[Start]
- dbo.Start
- Start
This is my regex:
"^((\[)?dbo(\])?)?(\.)?(\[)?Start(\])?$"
All 3 forms returns success but there are some more options such as: [dboStart
or dbo[Start
I know that this is because it is optional, but how could I make dependencies when making optional, so that if one optional has value then the second optional must have a value too.
Could you help me please to fix this?
Thanks.
© Stack Overflow or respective owner