Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: dhrobertsonOriginally posted by: stonysmith
This bit of code would probably do what you need:
leftpart=left(PLACEID,3) #get the repeating portion
position=strFind(substr(PLACEID,2),leftpart)+2 #find where it repeats
leftpart=left(PLACEID,position) #split off the left side
rightpart=substr(PLACEID,position) #split off the right side
emit PLACEID,leftpart,rightpart,position
What I have gone with in the end based on your example above (thanks very much by the way!) is as follows:
leftpart=left(PLACEID,3) # get repeating string
subset = substr(PLACEID,3) # get field, minus the first repeating string
position = strFind(subset, leftpart) # get the offset position of the second repeating string
offset= subset.len()- position # find the start of the new field by subtracting the offset position from the field length to give the start of the new field
final = right(subset,offset) # take from the right based on value of offset
I think this should be repeatable each time as long as the repeating part is always 3 characters in length, which in my case it should be.