In T-SQL, I generated UNIQUEIDENTIFIER using NEWID () . For instance:
723952A7-96C6-421F-961F-80E66A4F29D2
Then all dashes ( - ) are deleted and looks like this:
723952A796C6421F961F80E66A4F29D2
Now I need to turn the line above into a valid UNIQUEIDENTIFIER using the following format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and set the dash again.
To do this, I use the SQL CLR implementation of the C# RegexMatches with this regular expression ^.{8}|.{12}$|.{4} , which gives me the following:
SELECT * FROM [dbo].[RegexMatches] ('723952A796C6421F961F80E66A4F29D2', '^.{8}|.{12}$|.{4}')

Using the above, I can easily build the correct UNIQUEIDENTIFIER , but I wonder how the OR operator in the regular expression is computed. For example, the following will not work:
SELECT * FROM [dbo].[RegexMatches] ('723952A796C6421F961F80E66A4F29D2', '^.{8}|.{4}|.{12}$')

I’m not sure if the first regular expression will first match the beginning and end of the line, and then to other values and always return matches in that order (I will have problems if, for example, 96C6 after 421F ).
gotqn source share