[PR #857] [CLOSED] [WIP] Allow Regex in Rules set action #3369

Closed
opened 2026-02-28 20:40:35 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/857
Author: @ostat
Created: 4/5/2023
Status: Closed

Base: masterHead: regex_rules_set


📝 Commits (8)

  • b52c6ea WIP Regex rules
  • 7378207 regex unicode and ignore case support
  • 20eb532 Regex actions MVP
  • d9176de Merge branch 'master' into regex_rules
  • 61ec068 correct regexp rule matching
  • 39ce95b style cleanup
  • 8deb392 Merge remote-tracking branch 'Bryce-MW/master' into regex_rules_set
  • 4df68f1 WIP, allow regexp in the rules set

📊 Changes

11 files changed (+115 additions, -10 deletions)

View changed files

📝 packages/desktop-client/src/components/modals/EditRule.js (+1 -1)
📝 packages/loot-core/src/platform/server/sqlite/index.electron.ts (+6 -1)
📝 packages/loot-core/src/platform/server/sqlite/index.web.ts (+3 -0)
📝 packages/loot-core/src/server/accounts/rules.js (+43 -2)
📝 packages/loot-core/src/server/accounts/rules.test.js (+31 -0)
📝 packages/loot-core/src/server/accounts/transaction-rules.js (+6 -3)
📝 packages/loot-core/src/server/accounts/transaction-rules.test.js (+15 -0)
📝 packages/loot-core/src/server/accounts/transactions.js (+1 -1)
📝 packages/loot-core/src/server/aql/compiler.js (+4 -0)
📝 packages/loot-core/src/server/main.js (+2 -1)
📝 packages/loot-core/src/shared/rules.ts (+3 -1)

📄 Description

Building on allowing Regexp in the rules when matching. This is to allow Regexp rules in the set action.
We suspect the UI will need updating to support this, but for now the set field is being split for the required parts.

This feature will allow two user actions.

  • User rules to set one field to another filed.
  • Manipulate the field value when setting.

When creating a rule the user can apply regexp in the set field using the patter regexp[|]<inputfield>[|]<the regex>[|]<the replace expression>.
for example

setting field value output
regexp[|]imported_payee[|].*REF: (.*)[|]ref $1. Amazon ref: 127sj72 ref 127sj72
regexp[|]imported_payee[|].*Balance Offset.([\d,\.]*)[|]Offset Saved $1 Int Saved by Balance Offset 390.00 Offset Saved 390.00
regexp[|]imported_payee[|](.*)[|]$1 Closing Balance 98,000.00 Closing Balance 98,000.00

Sample file with transactions to match the examples given.
test-regexp.csv

example usage
image
image
image

@albertogasparin assisted with this change, be good to get their input.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/857 **Author:** [@ostat](https://github.com/ostat) **Created:** 4/5/2023 **Status:** ❌ Closed **Base:** `master` ← **Head:** `regex_rules_set` --- ### 📝 Commits (8) - [`b52c6ea`](https://github.com/actualbudget/actual/commit/b52c6ea0a4f767e155a4f0d56ff31526d1014b34) WIP Regex rules - [`7378207`](https://github.com/actualbudget/actual/commit/7378207591822782708195d52bb7a7cbe35b03b6) regex unicode and ignore case support - [`20eb532`](https://github.com/actualbudget/actual/commit/20eb532f3fa0791cfc3a98d613e61dfdf326dd96) Regex actions MVP - [`d9176de`](https://github.com/actualbudget/actual/commit/d9176deb8067c5b124f5cbce5c680c437f0fca3d) Merge branch 'master' into regex_rules - [`61ec068`](https://github.com/actualbudget/actual/commit/61ec0685717472f3cdeac6b9415ea7901936891c) correct regexp rule matching - [`39ce95b`](https://github.com/actualbudget/actual/commit/39ce95b450bf02ada6f49ab3d706785f321e5413) style cleanup - [`8deb392`](https://github.com/actualbudget/actual/commit/8deb392af2a9c73f58eb02e16ddd12d0a96e3765) Merge remote-tracking branch 'Bryce-MW/master' into regex_rules_set - [`4df68f1`](https://github.com/actualbudget/actual/commit/4df68f194a0fbcb0e48b201024ec18248f4d0668) WIP, allow regexp in the rules set ### 📊 Changes **11 files changed** (+115 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `packages/desktop-client/src/components/modals/EditRule.js` (+1 -1) 📝 `packages/loot-core/src/platform/server/sqlite/index.electron.ts` (+6 -1) 📝 `packages/loot-core/src/platform/server/sqlite/index.web.ts` (+3 -0) 📝 `packages/loot-core/src/server/accounts/rules.js` (+43 -2) 📝 `packages/loot-core/src/server/accounts/rules.test.js` (+31 -0) 📝 `packages/loot-core/src/server/accounts/transaction-rules.js` (+6 -3) 📝 `packages/loot-core/src/server/accounts/transaction-rules.test.js` (+15 -0) 📝 `packages/loot-core/src/server/accounts/transactions.js` (+1 -1) 📝 `packages/loot-core/src/server/aql/compiler.js` (+4 -0) 📝 `packages/loot-core/src/server/main.js` (+2 -1) 📝 `packages/loot-core/src/shared/rules.ts` (+3 -1) </details> ### 📄 Description Building on allowing Regexp in the rules when matching. This is to allow Regexp rules in the set action. We suspect the UI will need updating to support this, but for now the set field is being split for the required parts. This feature will allow two user actions. - User rules to set one field to another filed. - Manipulate the field value when setting. When creating a rule the user can apply regexp in the set field using the patter `regexp[|]<inputfield>[|]<the regex>[|]<the replace expression>`. for example |setting|field value|output| |--|--|--| |`regexp[\|]imported_payee[\|].*REF: (.*)[\|]ref $1`.|Amazon ref: 127sj72|ref 127sj72| |`regexp[\|]imported_payee[\|].*Balance Offset.([\d,\.]*)[\|]Offset Saved $1`|Int Saved by Balance Offset 390.00|Offset Saved 390.00| |`regexp[\|]imported_payee[\|](.*)[\|]$1`|Closing Balance 98,000.00|Closing Balance 98,000.00| Sample file with transactions to match the examples given. [test-regexp.csv](https://github.com/actualbudget/actual/files/11158646/test-regexp.csv) example usage ![image](https://user-images.githubusercontent.com/2128234/230074698-1c36574b-73e8-4f6d-8737-5c9e50718cda.png) ![image](https://user-images.githubusercontent.com/2128234/230077152-538c4138-71c6-4671-8f60-00b5f187b18b.png) ![image](https://user-images.githubusercontent.com/2128234/230077577-e02bca23-f7a9-409b-b333-8617b393401a.png) @albertogasparin assisted with this change, be good to get their input. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-02-28 20:40:35 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#3369