Getting leftmost or rightmost valid characters using regex
===

I am looking for regular expressions compatible with Regex.Replace in .NET to filter down user input to the leftmost or rightmost valid characters.  For instance if i need to get only uppercase characters I can do:

    var userText = "Ukeaf-4Det";
    var userPattern = @"[^A-Z]";
    var validText = Regex.Replace(userText, userPattern, "")

will return UDT but I need the userPattern to specify leftmost 2 digits so UD in this case.  Likewise, I need a separate userPattern that would do the rightmost 2 digits (DT in this example).

Is this possible to do with a single Regex pattern and how?

