Text: Parsing string and returning result

Hello all,

Always appreciate this forum the one place I go for HELP?!?!! :slight_smile:

Objective:

  1. Have a string “HELLO World” or “Hello World”
  2. Need to return back just the first part of the string. Everything from the " " (space) to the beginning.
    ex. “HELLO World” or "Hello World returns “Hello” or “Hello”
  3. How do you make the proper Title format for the text “HELLO” to “Hello” in the returned value of the string

Any help would be greatly appreciated.

TIA

Hi,

try this


set a to "HELLO world"
set b to word 1 of a
set c to character 1 of b & (do shell script "/bin/echo " & quoted form of text 2 thru -1 of b & " | /usr/bin/tr  A-Z a-z")

thanks for the help. This is why this place is awesome. :slight_smile:


set a to "HELLO world"
set b to word 1 of a
set c to character 1 of b & (do shell script "/bin/echo " & quoted form of text 2 thru -1 of b & " | /usr/bin/tr A-Z a-z")

  1. How do you adjust the above script to always make the first letter a capital? (thought it was working but it isn’t…

example
“Hello World” to “Hello”
“hello World” to “Hello”

thanks

set a to "HELLO world"
set b to word 1 of a
set c to character 1 of ¬
	(do shell script "/bin/echo " & a & " | /usr/bin/tr a-z A-Z") & ¬
	(do shell script "/bin/echo " & quoted form of text 2 thru -1 of b & " | /usr/bin/tr A-Z a-z")

here you go.