I need to match the account numbers from a large text file. Account numbers will be in the following format:
- Account Number: 123456
- Acct 4567
- Acct Number: 123-456-789
- Account Number 134-456-789
- Account # 111111
I need a regular expression that checks every line starting with "Acc", ignores the space and any special character, and then ends with a numeric one.
I wrote the following regular expression. The problem is that it matches some account number options. For example, this corresponds to # 1 and # 2, but not # 3 and # 4. Account numbers do not have a fixed length, and, as you can see, there are different options for the "Account Number" line
Any help or recommendation on fine tuning would be greatly appreciated.
(Acc[^0-9]*[0-9]*)
source
share