Hello all,
I have the following text (all on the same line):
I'm trying to replace every other comma (,) with a new line character (\n). So it looks like this:
I'm trying to do this with regex:
This is the substitution:
This yields the first number (180.00) followed by a new line character for each number (each line is blank) and the last number with a comma preceding it (,14).
Check it out:
Any idea what I'm doing wrong? I'm trying to do this in python:
Thank you!
I have the following text (all on the same line):
Code:
180.00,1,185.00,35,190.00,122,192.00,30,192.50,8,193.00,23,193.50,0,194.00,90,194.50,91,195.00,260,195.50,10,196.00,91,196.50,217,197.00,124,197.50,12,198.00,773,198.50,102,199.00,491,199.50,251,200.00,1065,200.50,555,201.00,838,201.50,1832,202.00,1237,202.50,2192,203.00,2495,203.50,1415,204.00,1405,204.50,2180,205.00,3978,205.50,4831,206.00,5447,206.50,2729,207.00,5900,207.50,3312,208.00,8487,208.50,4478,208.80,7,209.00,10739,209.50,5099,210.00,23449,210.50,5977,211.00,59360,211.50,13462,212.00,13171,212.50,15931,213.00,18177,213.50,19773,214.00,5668,214.50,3760,215.00,41943,215.50,5613,216.00,2582,216.50,1949,217.00,5490,217.50,2856,218.00,3166,218.50,2252,219.00,1522,219.50,10,220.00,2541,222.50,3779,225.00,4293,227.50,2584,230.00,10921,232.50,3201,235.00,29,237.50,1318,240.00,10,175.00,19361,180.00,12777,185.00,25723,189.00,959,189.50,644,190.00,13992,190.50,959,191.00,342,191.50,44,192.00,1763,192.50,19280,193.00,838,193.50,2715,194.00,3483,194.50,2584,195.00,7698,195.50,2773,196.00,2725,196.50,2211,197.00,2599,197.50,9471,198.00,52926,198.50,3211,199.00,7091,199.50,3242,200.00,29001,200.50,2029,201.00,15542,201.50,4715,202.00,25876,202.50,9145,203.00,42741,203.50,3402,204.00,24342,204.50,5918,205.00,61185,205.50,7675,206.00,36681,206.50,24690,207.00,16062,207.50,6575,208.00,30383,208.50,6694,208.80,3,209.00,10736,209.50,6833,210.00,19954,210.50,2774,211.00,2513,211.50,268,212.00,1113,212.50,159,213.00,332,213.50,106,214.00,232,214.50,72,215.00,32372,215.50,29,216.00,23,216.50,40,217.00,2,217.50,48,218.50,1,219.00,80,220.00,91,225.00,14
I'm trying to replace every other comma (,) with a new line character (\n). So it looks like this:
Code:
180.00,1
185.00,35
190.00,122
etc...
I'm trying to do this with regex:
Code:
(,(?:(?!,).)*),((?:(?!,).)*)
This is the substitution:
Code:
\1\n\2
This yields the first number (180.00) followed by a new line character for each number (each line is blank) and the last number with a comma preceding it (,14).
Check it out:
Code:
180.00
,14
Any idea what I'm doing wrong? I'm trying to do this in python:
Code:
parsedtext = re.sub(r"(,(?:(?!,).)*),((?:(?!,).)*)", "\1\n\2", textfield)
Thank you!
