[GNC] filtering in report

Geoff cleanoutmyshed at gmail.com
Mon Feb 7 19:21:38 EST 2022


Hi Andy

You said:
 > Next step is trying the complement: "[^uo][^br]$"
 > But this does not work as "Anzeiger" ist although filtered out.

Because you are anchoring the pattern match to the end of the account 
name (with the '$'), and specifying two character classes (with the 
'[]') this pattern actually means to match if:

Second-Last character is not 'u' AND
Second-Last character is not 'o' AND
Last character is not 'b' AND
Last character is not 'r'

Thus 'Anzeiger' is filtered out because its last character is 'r'.


Remember that your first pattern, which worked, is:

Second-Last character is 'u' OR
Second-Last character is 'o'
  AND
Last character is 'b' OR
Last character is 'r'


I think that the logical complement of this is:
(See https://en.wikipedia.org/wiki/De_Morgan%27s_laws)

NOT Second-Last character is 'u' AND
NOT Second-Last character is 'o'
  OR
NOT Last character is 'b' AND
NOT Last character is 'r'

Which, as a regular expression, is:

([^uo].)|(.[^br])$

Explanation:
Parentheses '()' means a group or sub-group
Pipe '|' means OR
Full stop '.' means 'match any single character'


I think this should work, give it a try!

Regards

Geoff
=====


On 8/02/2022 7:18 am, Andy wrote:
> Hi Geoff,
> 
> thanks for the detailed description!!
> 
> Yes, I work with 'Transaction Report'.
> 
> Unfortunately it is not so easy:
> The number of accounts in the tree differs, I cannot start from the 
> beginning. So I start at the end: "[br]$" to check that all accounts 
> ending with "chor" and "club".
> 
> As this finds "Anzeiger" too I modified to "[uo][br]$", which works 
> fine. Next step is trying the complement: "[^uo][^br]$"
> But this does not work as "Anzeiger" ist although filtered out.
> 
> I do not really understand why this does not work.
> 
> best regards
> Andy
> 
> 
> Am 07.02.22 um 02:57 schrieb Geoff:
>>
>> ... Which leads us to a possible hacky workaround for your scenario - 
>> this regular expression will do the job - see attached screenshot for 
>> proof:
>>
>> ^.+:.+:.+:[^GR]
>>
>> For those not familiar with the arcane art of regular expressions, 
>> let's break this down.  Remember that my chart of accounts is slightly 
>> different to yours, and I have a colon ':' as a delimiter, not a full 
>> stop '.'  Thus my accounts are:
>>
>> Expenses:Farm:RedCar:Gas,
>> Expenses:Farm:Tractor1:Repairs,
>> etc.
>>
>> To adapt this for your chart of accounts you need to remember (a) that 
>> a full stop in a regular expression means 'match any character', and 
>> to match just a full stop you need to 'escape' it with a backslash '\' 
>> ; and (b) that regular expressions are case sensitive.  Therefore this 
>> expression should (I hope) work for you:
>>
>> farm\..+\.[^gr]
>>
>> or failing, try this:
>>
>> farm\.[^.]+\.[^gr]
>>
>>
>> I said that this was a 'hacky' workaround, but given 26 upper case 
>> letters [A-Z] and 26 lower case letters [a-z] plus 10 digits [0-9] a 
>> careful, if slightly clunky, account naming convention could deliver 
>> you a workable and very flexible solution with up to 62 distinct child 
>> accounts.
>>
>> I hope this all makes sense ;--)
>>
>> In passing I also note that there *is* an option to negate the 
>> Transaction Filter - but this probably doesn't suit your needs.
>>
>> Regards
>>
>> Geoff
>> =====
>>
>>


More information about the gnucash-user mailing list