Is there a keyword modifier that could change a number to print the corresponding letter in the alphabet - e.g. 1 = A; 2 = B, 3 = C; etc.?
I'm using an asset listing to display points on a static Google Map. The asset_position keyword is used as the label on the map marker. However, the Google Maps markers are limited to a single character (0-9). After 9, the markers display a dot.
and keep going. Not sure what you want to do once it gets over 26. Perhaps you can do ^modulo:26 first, then it would cycle through the alphabet again.
The ' ^trim' modifier is necessary. The space provides the FALSE option in the conditional (otherwise you get a heap of 0's), and the trim removes the space again (otherwise you end up with a heap of spaces).
I'm sure better minds than mine could come up with a brilliant regex or similar.
Note: I can't test this at the present so can't guarantee it would work, and I've also had issues using modifiers on the asset_position keyword before (basically they didn't work), but I think that has been fixed in later versions.
I've come across a problem with this solution. I've set up a Regular Expression asset which has the following Regex and Replacement pairs:
/1/ - A
/2/ - B
/3/ - C
...
/25/ - Y
/26/ - Z
On my type format bodycopy I use the following keyword and modifier:
%asset_position^preg_replace:[REGEXasset#]%
However the problem begins when the position hits double digits. For 10 onwards it's displaying 'A0', 'AA', 'AB', etc. instead of 'J','K','L', etc. Regex isn't really my strong point, is there a simple solution to this?
You just need to append some constant character to the asset position keyword, and then update the regex asset to match a string that is the number sequence followed by the character.
You could use the append or replace modifiers to add the the character in the listing eg:
Sorry to hijack, I'm definitely not expert in regex but it looks to me like the confusion is that the first 9 positions will always be a substring of a subsequent position. In programming vernacular you're doing a string compare rather than a numeric compare. I'm sure this is not a new problem in regex and cannot believe there is not some way to cater for this, but I'm wondering whether you couldn't do something like:
I did some testing and in some ways the RegEx Bart recommended is very elegant and in others its butt ugly, but it can work. Here's a series of RegExes that will do what you want if you need to go above 26 items:
/^1$/ = A
/^2$/ = B
/^3$/ = C
/^4$/ = D
/^5$/ = E
/^6$/ = F
/^7$/ = G
/^8$/ = H
/^9$/ = I
/^10$/ = J
/^11$/ = K
/^12$/ = L
/^13$/ = M
/^14$/ = N
/^15$/ = O
/^16$/ = P
/^17$/ = Q
/^18$/ = R
/^19$/ = S
/^20$/ = T
/^21$/ = U
/^22$/ = V
/^23$/ = W
/^24$/ = X
/^25$/ = Y
/^26$/ = Z
/^27$/ = AA
/^28$/ = AB
/^29$/ = AC
/^30$/ = AD
/^31$/ = AE
/^32$/ = AF
/^33$/ = AG
/^34$/ = AH
/^35$/ = AI
/^36$/ = AJ
/^37$/ = AK
/^38$/ = AL
/^39$/ = AM
/^40$/ = AN
/^41$/ = AO
/^42$/ = AP
/^43$/ = AQ
/^44$/ = AR
/^45$/ = AS
/^46$/ = AT
/^47$/ = AU
/^48$/ = AV
/^49$/ = AW
/^50$/ = AX
/^51$/ = AY
/^52$/ = AZ
/^53$/ = BA
/^54$/ = BB
/^55$/ = BC
/^56$/ = BD
/^57$/ = BE
/^58$/ = BF
/^59$/ = BG
/^60$/ = BH
/^61$/ = BI
/^62$/ = BJ
/^63$/ = BK
/^64$/ = BL
/^65$/ = BM
/^66$/ = BN
/^67$/ = BO
/^68$/ = BP
/^69$/ = BQ
/^70$/ = BR
/^71$/ = BS
/^72$/ = BT
/^73$/ = BU
/^74$/ = BV
/^75$/ = BW
/^76$/ = BX
/^77$/ = BY
/^78$/ = BZ
/^79$/ = CA
/^80$/ = CB
/^81$/ = CC
/^82$/ = CD
/^83$/ = CE
/^84$/ = CF
/^85$/ = CG
/^86$/ = CH
/^87$/ = CI
/^88$/ = CJ
/^89$/ = CK
/^90$/ = CL
/^91$/ = CM
/^92$/ = CN
/^93$/ = CO
/^94$/ = CP
/^95$/ = CQ
/^96$/ = CR
/^97$/ = CS
/^98$/ = CT
/^99$/ = CU
/^100$/ = CV
/^101$/ = CW
/^102$/ = CX
/^103$/ = CY
/^104$/ = CZ
/^105$/ = DA
/^106$/ = DB
/^107$/ = DC
/^108$/ = DD
/^109$/ = DE
/^110$/ = DF
/^111$/ = DG
/^112$/ = DH
/^113$/ = DI
/^114$/ = DJ
/^115$/ = DK
/^116$/ = DL
/^117$/ = DM
/^118$/ = DN
/^119$/ = DO
/^120$/ = DP
/^121$/ = DQ
/^122$/ = DR
/^123$/ = DS
/^124$/ = DT
/^125$/ = DU
/^126$/ = DV
/^127$/ = DW
/^128$/ = DX
/^129$/ = DY
/^130$/ = DZ
/^131$/ = EA
/^132$/ = EB
/^133$/ = EC
...
I wrote a small bit of PHP to generate the regexes which I then copied and pasted in: