set theNoteTitle to "azerty [the title] zzzz"
display dialog theNoteTitle --1
set theX to offset of "[" in theNoteTitle
if theX is not 0 then
set theText to text (offset of "[" in theNoteTitle) thru -1 of theNoteTitle # EDITED
display dialog theText --2
set theText to rstripString(theText, "]") of me
display dialog theText --3
else
set theText to "1d"
end if
-- and on to do things to the Note!!
on rstripString(theText, trimString)
local theText, trimString, x
try
# EDITED
try
repeat until theText ends with trimString # EDITED
set theText to text 1 thru -2 of theText # EDITED
end repeat
return theText
on error number -1700
return ""
end try
on error eMsg number eNum
error "Can't trimBoth: " & eMsg number eNum
end try
end rstripString