Hi All,
I’m looking for a simple/elegant solution for a formula/script that will produce what I’m looking for.
I have a text field (it will have a maximum of 9 ALPHA (uppercase only) characters in it. I’m looking for a solution that will perform the following functions.
a. If a character is contiguous to itself if will count the total contiguous characters and place the number followed by the character. For example if the text field was PPPPP I would get a result of 5P.
b. If a character has no contiguous matches then the result would just be the characters as shown. For example QRSTUV would give a result of QRSTUV.
c. Combining these two rules together if we were to have RRQRRRQS the result would be 2RQ3RQS. I can easily find a solution if I wanted the result of an input sting of RRQRRRQS to be 5R2Q1S but the sequence has to remain as was originally shown as each value is assigned to a corresponding column (column 1 through 9 which is associated with a quantity level) so this wont work.
Here is some actual data and the desired results.
| Count | String | Desired Result |
|---|---|---|
| 1 | RSSSSTTZZ | R4S2T2Z |
| 2 | RRSSSST | 2R4ST |
| 3 | QRSSSST | QR4ST |
| 4 | PRRRRST | P4RST |
| 5 | RRSSSTT | 2R3S2T |
| 6 | RSSSSTT | R4S2T |
| 7 | PQRRRST | PQ3RST |
| 8 | PRRRRST | P4RST |
| 9 | RRRRRST | 5RST |
| 10 | RQRRRST | RQ3RST |
| 11 | PRRRRST | P4RST |
| 12 | RRSSSTT | 2R3S2T |
| 13 | RRRRRST | 5RST |
| 14 | RRRRRST | 5RST |
| 15 | QRRRRST | Q4RST |
| 16 | QRRRRST | Q4RST |
| 17 | QPQRRST | QPQ2RST |
| 18 | RRSSSST | 2R4ST |
Any thoughts or suggestions on how to proceed are much appreciated!
Tom
