Regular expressions in account_statement_rules

As a followup on Rules / regular expression with account_statement_rule I’m struggling with the regular expression part of the different fields.

Can anybody give some examples how to do regular expressions and what they do? For example I want to look for parts in a string. Also the help text talks about several groups, how apply them and what do they do?

I think for many of you it’s a piece of cake but for somebody else it’s a pain to understand regular expression. And examples is a way to get a basic understanding what we have to put in the different fields. So any help is very appreciated.

So there is a detailed howto on regular expressions here: Regular Expression HOWTO — Python 3.12.1 documentation

However, if you are only looking for parts in a string you don’t need to worry about the groups, and probably won’t really need to worry too much about the fact that they are regular expressions.

So for example using these descriptions for statement origins:

 Supermarket Store 1234, Somewhere
 Insurance DD, 12345678
 Supermarket Store 9876, Elsewhere
 Customer Payment from Name, Somewhere

With the statement rule’s description if you just put:

  • “Supermarket” it will match the 1st and 3rd lines.
  • “1234” would match the first and 2nd lines.
  • “Somewhere” would match the 1st and 4th lines.
  • “[0-9].*s” should match the 3rd line (“[0-9]” matches any digit, followed by “.*” which matches any character (“.”) zero or more times (“*”), followed by a lowercase “s”)

Hopefully I’ve explained that well enough, but let me know if it isn’t too clear.

Thanks, that clears a lot! And like you said, I don’t have to worry too much about this, as I’m just looking for words in the string. I can just fill in the word and that’s it.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.