I have the following regex to match this:
U$MichaelU$P@$asdqwe123P@$ - this is correct; the other two are not
U$NameU$P@$PasswordP@$
U$UserU$P@$ad2P@$  
A registration is valid when:
- The username is surrounded by "U$"
- The username needs to be minimum 3 characters long, start with an uppercase letter, followed only by lowercase letters
- The password is surrounded by "P@$"
- The password needs to start with minimum 5 alphabetical letters (not including digits) and must end with a digit
My regex is
@"^(U\S)([A-z][a-z]{3,})\1(P@\S)([a-z]{5,}[^\d])([\d]+)\3$"
The problem is that it matches the first one but when I submit to the judge it passes first 2 test but the rest it breaks, could you please tell me where is my mistake.

\Sto match a$.\Smatches many other characters as well. Also, the regex looks for a minimum of 4 letters in the name, not 3, and 6 non-digits in the password, not 5.