Reply to topic

Question on Skrooge - regexp on Search and Process

jeleb
Registered Member
Posts
4
Karma
0
Hi there,

I use skrooge, and I'm very happy with it 8)
My bank exports have a beneficiary field like :
"MyShopName CARTE 12345678 PAIEME"
or
"MyShopNameLonger CARTE 12345678 P"

The beneficiary field contains the CB card number with variable length, from "CARTE 12345678 PAIEMENT CB" to "CARTE 1234"
I want to modify this field without "CARTE ..."
With regexp, i can find all records. Something like : ".* CARTE 1234.*"
But how I remove this part ?
Can I do something like :
search : regexp << (.*) CARTE 1234.*>>
process : =$1

Thnak you
User avatar smankowski
Moderator
Posts
983
Karma
7
OS
No, this is not possible to extract value from regexp.
Because the idea is good, I will add it in my todo list.


Skrooge, a personal finances manager powered by KDE
Image
User avatar smankowski
Moderator
Posts
983
Karma
7
OS
This is implemented: https://cgit.kde.org/skrooge.git/commit ... f5b28d9162
You will have it in next version 2.20.0.
Regards.


Skrooge, a personal finances manager powered by KDE
Image
jeleb
Registered Member
Posts
4
Karma
0
Fabulous ! I'm waiting for this new version !
Thank you !
cousinmarc
Registered Member
Posts
2
Karma
0
Hi, Sorry to come here so late.

As a long time regexp user, I think it's a bit weird the way the replacement is implemented. It seems like in the replacement string, one can only use the id of one capture string, which is not quite what a regexp user would be expecting. But maybe I misread the C++ code, I haven't been writing some for a long time...

Let's say I'm using this regexp:

\d+\/\d+\/\d+ .*( \d{4})? (.*)

I'm matching a date, then a string I don't care about, then 4 numbers with a space that may be there or not (and that I'm capturing), another random string that I'm capturing too, etc… I may want to extract several parts of the incoming string.

In the "new string" part, all I can put right now (but I may be mistaken), is ONE number, indicating one thing I captured. With regexp (sed, awk, grep, perl…), you'd be expecting to be able to put a replacement string with more functionality, like

"$2 -> $1", which would mean print the second capture, then ->, then $1

I think the feature would be much more useful if it was possible to do this. I can still do this with several stages of filters, but that's quite awkward.

Anyway, thanks for skrooge, great tool.
cousinmarc
Registered Member
Posts
2
Karma
0
While I'm using this feature, I feel there may be something more missing… is there a way to specify that a replacement should only be performed only if the regexp matches ?

 
Reply to topic

Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], jerrybx, JOEHONKEY, Sogou [Bot], uriel, Yahoo [Bot], yakamotosu