Comments (4)
from hledger-vscode.
Here's a robust pattern, that allows for rates in the form of @@
/ @
and comments using ;
/#
/*
as well. It tries to follow hledger
's logic as far as I can tell.
In .NET/C#:
(?<=\S+[ ]{2,}@?[^;#*\n]*)(""[^;\\\n]+""|[^-+.,@*;\t\n ""{}=\d]+)
in JS:
(?<=\S+[ ]{2,}@?[^;#*\n]*)("[^;\\\n]+"|[^-+.,@*;\t\n "{}=\d]+)
Explanation:
- Lookbehind
(?<=…)
to check if there's
a. one ore more non-whitespace characters\S+
b. followed by at least 2 blank spaces[ ]{2,}
c. optionally followed by an @ symbol@?
d. followed by zero or more characters that aren't comment markers[^;#*\n]*
- Then match either:
a. quoted text without prohibited characters:"[^;\\\n]+"
b. or (|
) simple commodity symbol without any digits, or other prohibited characters:[^ -+.,@*;\t\n"{}=\d]+
I tried the JS version on my journal in vscode
, via the find bar, it works within a split second. I'm not sure how to time it to the milliseconds.
You could translate it to the appropriate regex engine.
https://regex101.com/r/fGhYrY/6
from hledger-vscode.
from hledger-vscode.
Could you explain / break down your regex into parts with comments? It’s very long
I edited my reply to add an explanation:
#264 (comment)
from hledger-vscode.
Related Issues (14)
- Currency codes get highlighted in the middle of posting descriptions
- Tests failing after vscode-textmate update HOT 4
- Can't run tests: unable to compile typescript
- Timedot support HOT 1
- Unable to install on Arch Linux (needs to be published on Open VSX) HOT 3
- [Feature Request] Parser error reporting HOT 7
- [Feature Request] Journal Prettifier HOT 5
- Syntax coloring for effective dates HOT 11
- Syntax highlighting for "revenue" in addition to "income" HOT 1
- Hashtags in transaction descriptions are being highlighted as comments HOT 1
- Generalize account syntax HOT 20
- Consider using vscode-tmgrammar-test for tests
- Can't compile oniguruma dependency HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hledger-vscode.