I have a question… why is this creating a list?
“e,m,a,i,l,@,a,o,l,.,c,o,m”
set email_addr to (characters ((offset of “(” in y) + 1) thru ((offset of “)” in y) - 1)) of y as text
?
I have a question… why is this creating a list?
“e,m,a,i,l,@,a,o,l,.,c,o,m”
set email_addr to (characters ((offset of “(” in y) + 1) thru ((offset of “)” in y) - 1)) of y as text
?
It’s not actually a list, Patrick. It’s a string containing loads of commas. A true list looks more like this: {“e”, “m”, “a”, “i”, “l”, “@”, “a”, “o”, “l”, “.”, “c”, “o”, “m”}
There are a few things you can do to avoid getting unexpected results like those above:
When you are using text item delimiters, make sure they’re finally set back to their initial value: {“”} (That’s a list containing an empty string). Your TIDs must have been set to “,” or {“,”}.
Instead of using ‘characters’ (which creates a list that needs to be coerced back to a string - the nature of which will depend on the current value of AppleScript’s text item delimiters), use ‘text’ for this particular type of job. That way, even if the TIDs are set to something completely whacky, your text won’t be affected by them (and your script will execute faster - because it’s not carrying out unnecessary coercions):
set email_addr to text ((offset of "(" in y) + 1) thru ((offset of ")" in y) - 1) of y