Get the first and the last char of a string

[Autolink] Menu

You can use PARSE also to split a string into first char, last char and all chars between the first and the last char.
Example:

 
/* split a string into first char, last char, and the chars between   */
/* (assuming the last char is unique in the whole string)             */

  nextLine = "[TestSection]"
  parse var nextline firstChar +1 . "" -1 lastChar,
                     1 (firstChar) SectionName (lastChar)

  say "The first char is <" || firstChar || ">"
  say "The last char is <" || lastChar || ">"
  say "The chars beteween are <" || sectionName || ">"


[Back: Swapping two variables without using a temp. variable]
[Next: How to use parse arg]