troubles delimiting

I have a phrase that I am having trouble delimiting. How can I trim off the end after .com in each case?

OR next2


Something like this should handle any of those:

set test to ""

set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {".com"}
set test to first text item of test & ".com"
set AppleScript's text item delimiters to ASTID

return test

Don’t forget the offset command from Standard Additions’ string commands, which is often overlooked. For many situations, it can be perfectly appropriate - and is usually a bit shorter and easier to use:

set t to ""
t's text 1 thru ((offset of ".com" in t) + 3)

thanks! Is there a way to do the opposite? lets say turn this




set t to "fgsfgff"
t's text (offset of "http:" in t) thru end

And yes, if you want to extract some text from somewhere in the middle of a string, you can achieve that with offset, too.