On 05/25/2021, at 23:19, Duncan Thorne <[email protected] 
<mailto:[email protected]>> wrote:
> Here's a sample line from my script where things go wrong:
> tell front text window's text
> 
> replace "2021
> 
> \$" using "   \$" options {search mode:grep, case sensitive:false, starting 
> at top:true} -- the idea being to take out a line break and replace it with a 
> tab.
> 
> end tell
> 


Hey Duncan,

Backslash is the escape character in AppleScript, so when you need to write it 
as a literal you have to escape the escape character.

set myDollarSign to "\\$"

I know this is often quite confusing to neophyte AppleScripters, so please 
forgive me for forgetting to mention it explicitly.

For future references here's how you'd write the regular expression in 
AppleScript:

tell application "BBEdit"
    tell front document
        replace "(2021)\\n(\\$)" using "\\1\\t\\2" options {search mode:grep, 
case sensitive:false, starting at top:true}
    end tell
end tell

If you take the literal strings (between the quotes) and replace the "\\" with 
"\" as a literal string in BBEdit you'll get unescaped version that BBEdit 
wants.

A perhaps simpler trick to see the literal string is to copy it to the 
clipboard like so:

set the clipboard to "(2021)\\n(\\$)"

--> (2021)\n(\$)

The part after “--> ” is the pasted result.

“--> ” is a writing convention for indicating the result of an AppleScript.

I too am a long time user of Tex-Edit Plus and will sorely miss it down the 
road.


--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/1D99E910-A13C-4F44-A723-43F76A17DE93%40gmail.com.

Reply via email to