How would one create a macro to select a continuous text string excluding the beginning and ending white spaces?
Example: given the following text
abc [#$/fox(/jumps/over)the/lazy/dog/123:-/93<82}=][\] 123
If mouse cursor is anywhere inside the text string, activating the macro would automatically select the full text string.
[#$/fox(/jumps/over)the/lazy/dog/123:-/93<82}=][\]
on extendToSpace(doc, isBackwards)
using terms from application "BBEdit"
tell doc to find "\\s" options ¬
{search mode:grep, extend selection:true, backwards:isBackwards} ¬
with selecting match
end using terms from
end extendToSpace
on run
tell application "BBEdit"
set docs to text documents
if 0 < (count of docs) then
set doc to front text document
if found of (my extendToSpace(doc, true)) then
if found of (my extendToSpace(doc, false)) then
tell text of doc
tell selection
set iStart to its characterOffset
set iEnd to iStart + ((its length) - 2)
end tell
select (characters iStart thru iEnd)
end tell
{iStart, iEnd}
else
"No space or newline found to right"
end if
else
"No space or newline found to left"
end if
else
"No document open in BBEdit"
end if
end tell
end run