regex having trouble consistently capturing data the 1st or 2nd line of a group

  • Thread starter Thread starter gg edm
  • Start date Start date
G

gg edm

Guest
I made a mistake somewhere in the regex expression

\r\n[%] Unrealized Gain/Loss
((?<curncy>[a-z][a-z][a-z])\s(?<cash>[0-9,]+\.\d+)\s(?<investmt>[[0-9,]+\.\d+)\s(?<ttl>[0-9,]+\.\d+)\s(?<book>[0-9,]+\.\d+).+
)+

in attempt to capture from a sample test data





% Unrealized Gain/Loss
CAD 3,691.40 42,051.37 45,742.77 38,584.59 +3,466.78 8.98% 
USD 99.29 1,797.92 1,897.21 1,079.91 +718.01 66.49%
,,,,
...many intervening lines other stuff
% Unrealized Gain/Loss
CAD 49,467.12 359,010.80 408,477.92 172,631.06 +186,379.74 107.96% 
USD 1,342.06 14,051.28 15,393.34 23,345.60 -9,294.32 (39.81%)
....many intervening lines...
% Unrealized Gain/Loss
CAD -66,328.51 463,285.92 396,957.41 153,349.26 +309,936.66 202.11% 
USD 209,709.44 9,320,875.71 9,530,585.15 792,400.38 +8,528,475.33 1,076.28%
....many intervening lines...
% Unrealized Gain/Loss
CAD 23,720.03 174,805.55 198,525.58 53,690.15 +121,115.40 225.58% 
USD 18,620.73 1,262,351.89 1,280,972.62 394,446.54 +867,905.35 220.03%
....many intervening lines...
% Unrealized Gain/Loss
CAD 3,230.17 3,167,580.00 3,170,810.17 44,492.96 +3,123,087.04 7,019.28%
....many intervening lines...
% Unrealized Gain/Loss
CAD 5,759.31 1,621.20 7,380.51 905.87 +715.33 78.97% 
USD 1,212.69 77,359.87 78,572.56 70,944.97 +6,414.90 9.04%




I got the following as captured result

USD 99.29 1,797.92 1,897.21 1,079.91
USD 1,342.06 14,051.28 15,393.34 23,345.60
USD 18,620.73 1,262,351.89 1,280,972.62 394,446.54
CAD 3,230.17 3,167,580.00 3,170,810.17 44,492.96
USD 1,212.69 77,359.87 78,572.56 70,944.97


what have I done wrong?

Continue reading...
 
Back
Top