Trying to answer myself an academic exercise here.
Is there a method using Regular Expressions (.net syntax, so see the caveat below) that I can convert fully qualified server name to a combo upper and lower case string (server name is UPPER case, domain name(s) in lower case).
e.g.
- db01.local => DB01.local
- DB02.TEST.LOCAL => DB02.test.local
- db03.LOCAL = > DB03.local
I've been playing around with the RE and so far have ([A-Za-z0-9-]+)\.(.+)
as the pattern, but I'm struggling how to do this in a simple one liner.
My initial tests had me fritzing with Matches
and getting a returned list, but that feels fugly to me because I then need to check the number of matches, do casting and ToUpper()
\ ToLower()
operations etc. and, yeah, well...
Caveat: If I wasn't using .NET then I think I should be able to do something simple like use \U${1}.\L${2}
as my replacement string, but it doesn't look like .NET supports that syntax.