Answered by:
Look for canonical pattern like word.word.word

Question
-
Hi
I need to validate some entries like
dataserver.database.datatable as you can see this canonical form a kind of hierarchy and dot between the three words
Reguards
Every one was a beginner onceSaturday, July 23, 2011 1:38 PM
Answers
-
Hi,Use case insesitive, or change [a-z] to [a-zA-Z] may be you need digits [a-zA-Z0-9] may be "_" symbol [a-zA-Z0-9_]
In my practice i have a situation where database have "." in name in this case is used [database].[scheme].[table] for example [Services.Users].dbo.User or [Services.Users].[dbo].[User]in this case we need other regex:^(([a-zA-Z0-9_]+)|(\[[a-zA-Z0-9_\.]+\]))(\.(([a-zA-Z0-9_]+)|(\[[a-zA-Z0-9_\.]+\]))){2}$i want to mentionate that^([a-z]+(\.|$)){3} - is wrong regex because it match "sadasd.as.qweqwe."
- Proposed as answer by Rotaru Anatol Monday, July 25, 2011 12:51 PM
- Marked as answer by moss888 Thursday, July 28, 2011 8:27 AM
Monday, July 25, 2011 12:50 PM
All replies
-
either the very simplest form:
^[a-z]+\.[a-z]+\.[a-z]+$
Or:
^[a-z]+(\.[a-z]+){2}$
or
^([a-z]+(\.|$)){3}
- Proposed as answer by WolfgangKluge Monday, July 25, 2011 8:21 AM
Saturday, July 23, 2011 3:32 PM -
Hi
Thank you for the answer however if I test this pattern against TEST.dbo.TAB for example it is not matching
Thank you
Every one was a beginner onceSaturday, July 23, 2011 3:45 PM -
-
Hi,Use case insesitive, or change [a-z] to [a-zA-Z] may be you need digits [a-zA-Z0-9] may be "_" symbol [a-zA-Z0-9_]
In my practice i have a situation where database have "." in name in this case is used [database].[scheme].[table] for example [Services.Users].dbo.User or [Services.Users].[dbo].[User]in this case we need other regex:^(([a-zA-Z0-9_]+)|(\[[a-zA-Z0-9_\.]+\]))(\.(([a-zA-Z0-9_]+)|(\[[a-zA-Z0-9_\.]+\]))){2}$i want to mentionate that^([a-z]+(\.|$)){3} - is wrong regex because it match "sadasd.as.qweqwe."
- Proposed as answer by Rotaru Anatol Monday, July 25, 2011 12:51 PM
- Marked as answer by moss888 Thursday, July 28, 2011 8:27 AM
Monday, July 25, 2011 12:50 PM -
Thank you a lot rotaru
Every one was a beginner onceThursday, July 28, 2011 8:28 AM