Split a line up into separate column
-
This is a a small example of the line i need to split into a separate column
ExperiencePointsForLevel[1]=2,ExperiencePointsForLevel[2]=4,ExperiencePointsForLevel[3]=7,ExperiencePointsForLevel[4]=12,ExperiencePointsForLevel[5]=19,ExperiencePointsForLevel[6]=27,
I read somewhere about counting the number of letters that would be between each column. That wouldn’t work for me because the number letters and numbers increase further down the line. I would also like to remove the , comma after the #'s.
-
@Warren60
Removing commas should be fairly easy. If they are the only ones and you want ALL removed the following regex would suffice.Find What:
,
Replace with:<empty field>
<— nothing in this field.As it is a simple regex the replace with function “search mode” could be normal or regular expression. I would however hold off on removing the commas as it seems they are useful in your other question (helping to arrange the data in columns).
With different columns, as you say it becomes a bit more complicated as the lengths will differ. However a way would be to make all the numbers equal length, so a 1 and a 123 would ALL become 001 and 123 (the length of the longest number. Then an appropriate number of spaces could be inserted between all to line them up. Then lastly another regex could eliminate the “0” and insert a space behind the =#. This would keep the length still the same and also keep alignment correct (assuming fixed width font).
So again (as stated previously) more info is needed, especially an afterwards example to your before example above. Then actual regexes could be produced for you.
Terry
-
@Warren60
I’ve been doing a bit of research on old posts here and found one that can easily line up the columns for you. Look at
https://notepad-plus-plus.org/community/topic/14717/column-aligning-jagged-data/5So I’d firstly use the comma to replace that with a number of spaces say about 10 or so. The actual number would depend on the maximum size of your number range used. You have 27 characters in
ExperiencePointsForLevel[]=
alone. Then you just need to add the length of the largest number to be assigned inside the [] and also the one after the = sign. Say you have 5 and 7 respectively, then you’d have 39 characters as the maximum length. You then need to figure out how far apart would the columns be, would it be say 40 (1 space minimum) or 45 which gives 6 spaces minimum. Let’s go with 6. So 45 less 29 (27 +1+1 minimums) give 17, so replace,
with17 spaces
(not actually spaces in my example).Once that has been achieved use the 3rd regex in the link above
^(.{12}) +
but replace 12 with 45, being the number we picked above. Replace all and that will align the 2nd column. Then replace 35 with 90 and repeat the replace all. Again change 70 with 135 and… you get the idea.Terry