There is no American standard for bank account numbers. However, NACHA provides an ACH transaction specification that provides an example of a DFI Account Number field:
The leftmost 17 characters are inserted into the account number of the DFI field, and the remaining characters are truncated .... If less than 17 characters, left align and leave unused spaces blank.
The DFI Account Number field as part of the CCD Entry Detail is indicated as alphameric '(ASCII values ββgreater than 0x1F).
Here is the regex with which I came. It does not match the full ASCII range, but I think that it will handle most account numbers. (17 characters consisting of a word, -., Alphanumeric with spaces if a barcode is present, not a serial, not an end)
^(?<DFIAccountNumber>(?=[\w\- ]{17})[0-9A-Za-z](\-?\w+)*[ ]*)
Jay walker
source share