stant / mdcsvimporter2015

GNU Lesser General Public License v3.0
13 stars 5 forks source link

Need Regex help #9

Closed ae8u closed 5 years ago

ae8u commented 5 years ago

I am trying to import csv files from my bank. The problem is the csv file shows negative values (expenses) with one minus sign and positive values (income) with two minus signs. When they are imported they all come in as expenses. Here is an example of my csv: posted,,12/31/2018,,INTEREST PAID,Interest,--0.03 posted,,11/30/2018,,INTEREST PAID,Interest,--0.03 posted,,10/31/2018,,INTEREST PAID,Interest,--0.03 posted,,09/28/2018,,INTEREST PAID,Interest,--0.03 posted,,08/31/2018,,INTEREST PAID,Interest,--0.03 posted,,07/31/2018,,INTEREST PAID,Interest,--0.05 posted,,07/23/2018,,USAA FUNDS TRANSFER DB,Transfers,-200 posted,,07/03/2018,,USAA FUNDS TRANSFER DB,Transfers,-1000 How do I convert the values with a double minus to income? I am guessing that there is a Regex that I can use, but that is beyond my ability. Can you help?

stant commented 5 years ago

"?(?:--){0,1}(?.?)"?(?:[,]|\Z)(?(.|\Z)) regex are hard. I am sorry, I did not see any email for issues. it looks like adding (?:--){0,1} in above takes out any -- which will make it positive. so "15" -> "15" "-15" -> "-15" "--15" -> "15" i found this regex tester that is helpful! db-minus

stant commented 5 years ago

I was not getting emails for issues. I now figured out how to turn that on. Hope that regex site helped.