Reversing Order of Characters in String

Do forgive, I must be blind if this is actually in the documentation. I am extracting an item from a CSV file - a string to be precise. When it comes into eggPlant, it looks as so:


I want to try and reverse the order of characters to that it looks like this:


Is there anyway this might be possible? I attempted using the reverse order command but I’m hitting walls there.

Any help welcome!

One of several possibilities:

 repeat with each character of myvalue
      put it before reversed
end repeat
put reversed

You can also do this with the unknown trick of using a reverse range of characters:

put chars 99..1 of "Geronimo!" into reversed
put reversed -- !ominoreG

If your text might be more than 99 characters long, then use a larger number or you’ll only get the first 99 characters reversed.

Thank you both for your replies! They were helpful! I do have another question though, I have a string that is a date. The format is YYYYMMDD with no slashes or periods to separate year, month, and date. Is there any sort of way I could do string parsing to insert?

Try this:

set myDate to "YYYYMMDD"
put "-" after chars (6,4) of myDate
put myDate

That will result in: YYYY-MM-DD. You will need to use the reverse order (6,4) as shown to get the result you want, because the insertions are done in the order given.

Well, if you know that that’s the format and it’s consistent, then you could say:

put 20020318 into theText
put the first 4 characters of theText into theYear
put characters 5 to 6 of theText into theMonth
put the last 2 characters of theText into theDay
put ((theMonth,theDay,theYear) joined by "/") as date into theDate
put theDate
put the day of theDate