Delimiters and Case

I’ve just noticed that text item delimiters won’t separate text if the case deosn’t match. For example,

set astid to AppleScript's text item delimiters
ignoring case
	set AppleScript's text item delimiters to "src"
	set a to text items of "<IMG SRC=BOB>"
	set AppleScript's text item delimiters to ""
end ignoring
set AppleScript's text item delimiters to astid
return a
--returns {"<IMG SRC=BOB>"}

But if I capitalize the delimiter, it works fine.
My question is, is there an easy way to get around this? Or do I have to go through with an upper and lower case version of the delimiters?

Hi,

AppleScript’s text item delimiters are case-sensitive when they’re applied to strings. However, when they’re applied to Unicode text, they obey the current setting of AppleScript’s ‘case’ attribute, which is, by default, ‘ignoring case’. If it suits your purpose, you could coerce your main text to Unicode first:

set mainText to "<IMG SRC=BOB>" as Unicode text

set astid to AppleScript's text item delimiters
ignoring case -- Optional. (The default.)
	-- The delimiter itself can be either string or Unicode text.
	set AppleScript's text item delimiters to "src"
	set a to text items of mainText
end ignoring
set AppleScript's text item delimiters to astid
return a
--> {"<IMG ", "=BOB>"} -- A list of Unicode texts.

That the way it works. Note offset ignores case.

set x to offset of "src" in "<IMG SRC=BOB>"
-->>6

But that would be a lot of work next to AppleScript’s text item delimiters multi pasting

. that is, it obeys the current setting of the ‘case’ attribute, which is ‘ignoring case’ by default. If you use ‘considering case’, ‘offset’ becomes case sensitive. This is only true since OS 10.3, I think. Before that, ‘offset’ was always case sensitive, with both strings and Unicode text.

Thanks!