|
From: | Freeman Gilmore |
Subject: | More Regexp help |
Date: | Sat, 27 Jun 2020 21:45:40 -0400 |
I have a string of accidentals and I want the sum of their deviation.
If I have the string, “a bx3 cd -jk -DRx2 rtyu -HJK 31 17x4 -7 -41x3” with all possible examples.
I want to convert it to, “ a (* b 3) -jk (* -DR 2) rtyu -HJK n31 (* n17 4) -n7 (* -n41 3)”
Then, (a (* b 3) -jk (* -DR 2) rtyu -HJK n31 (* n17 4) -n7 (* -n41 3)) . ( + will be applied to this)
1] Where “a” “cd” “-jk” “rtyu” “-HJK” are unchanged. (variables)
2] Numbers “31” “17x4” “-7” “-41x3” have “n” prefixed to them like, “n31” “n17x4” “-n7” “-n41x3”. (numbers converted to variables)
3] And “bx3” “-DRx2” “17x4” “-41x3” become “(* b 3)” “(* -DR 2)” “(* n17 4)” “(* -n41 3)”. (number of times variables are used)
This is way beyond my capability, and I would appreciate help with this. For my simple mind it would teach me more if this were done in say 3 steps rather than mapped.
Thank you,
[Prev in Thread] | Current Thread | [Next in Thread] |