The idea of using a regular expression is a good one. General format is:
You can use the classes in SAS.Task.Toolkit (SasServer class, Data.SasLibrary class) to verify that the server and library are valid (that they exist). These are in SAS.Task.Toolkit.dll, which you can use in your task (for EG 4.2).
I wish I had a code example handy, but this should give you something to look at.