it will depend on your flavor of the Regex language and the coding language (C #, PERL, etc.), but in C # you would do something like
string rX = @"\D+"; Regex.replace(input, rX, ""); return input.SubString(0, 5);
Note. I'm not sure about this regular match (others might be better here), but basically, since Regex doesnβt "replace" anything, just matching patterns, you have to look for any-digit characters; once you agree to this, you will need to replace it with the language version on the empty version (string.Empty or "" in C #), and then capture the first 5 characters of the resulting string.
source share