Your current regular expression is designed to capture any alphanumeric sequence (with optional dash and/or dot) that follows certain keywords like “Account #:”, “Account Number:”, “Acct:”, “Account:”, “ACCT NO.”, or “Account No.”. However, it doesn’t limit the match to only account numbers and therefore it’s also capturing “Transfer” if it follows any of these keywords.
To limit the match to only account numbers, you can restrict the characters allowed in the captured sequence. If your account numbers are always numeric with an optional dash and/or dot, you can modify the expression like this:
(?<=Account #: |Account Number:?|Acct:|Account:|ACCT NO.|Account No.)\s?[0-9-.]+(?=(.*\n)?)
This will match any sequence of numbers, dashes, or dots following the specified keywords.
If your account numbers can be alphanumeric but they have a specific pattern (for example, they always start with a letter followed by numbers), you can modify the expression to match this pattern. For example:
(?<=Account #: |Account Number:?|Acct:|Account:|ACCT NO.|Account No.)\s?[A-Za-z][0-9-.]+(?=(.*\n)?)
This will match any sequence that starts with a letter and is followed by numbers, dashes, or dots.
Please note that regular expressions are case sensitive by default. If the keywords can appear in different cases in your text, you may want to add the case-insensitive flag (?i) at the start of your expression:
(?i)(?<=Account #: |Account Number:?|Acct:|Account:|ACCT NO.|Account No.)\s?[A-Za-z][0-9-.]+(?=(.*\n)?)
I hope this helps! If you have any further questions or need more assistance, feel free to ask.