I'm trying to match data in a gnucash record, without skipping into the next record, so basically needing to stop matching at the closing tag. The record looks thus, for example:

   <split:id type="guid">57d4ffe92d4345ddb866e7ebb3429b36</split:id>
   <split:account type="guid">6b204fbd94654cc9ae53ffec5d8f05fc</split:account>

I am trying to find all records matching a reconciled state for a specific account, however beyond very basic regex matching I can't seem to limit the pattern inside the split, and no matter what I try, vim is selecting across as many records as it can find to match the guid.

Would appreciate some help as I have spent days on this.

Clarification: My goal is to be able to change the reconciled-state flag on all transactions in an account, so I need to be able to identify that the record belongs to that account. Something along these lines sort-of works:


The look-behind is, I believe, quite expensive and could probably be optimised, however the main issue is that if the immediate guid doesn't match, the search will cross the </trn:split> until a match is found. In order to contain the search, I need to limit it to 'match anything up to </trn:split>,' and this is where I am having the problem. I have tried different permutations of \(<\/trn:split>\)\@! inside the regex but the correct syntax is eluding me. :help @! gives a basic example that I'm not sure I fully grasp and helpfully states that negative assertions are tricky. It's also difficult to tell what the expression is matching since syntax highlight doesn't show zero-width assertions.

This may not even be the right approach, as advanced examples of matching seem to be few and far between. I think I have reached the point of diminishing returns as I am a bit stuck on what to try next.

  • 1
    It would be helpful if you clarified a bit your question: find all records matching a reconciled state for a specific account: Does that mean matching a whole <trn:split> tag having a <split:id> tag matching your guid? can't seem to limit the pattern inside the split are you talking about a Vim split which is a view of a buffer or something else? What have you tried so far? If you spent days on this you probably having a beginning of solution which would be useful for other to better understand what you're trying to do. – statox Jul 1 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.