Hello community, I've started to explore the possibilities of Regex in connection with the Search & Replace action.
I wanted to remove the green marked lines from an AppleScript of the UI Browser, in the Script Debugger:
-- Use this script as a wrapper for GUI Scripting statements when you are confident that GUI Scripting is available and enabled or that the user knows how to enable it if necessary
activate application process "Drafts"
tell application "System Events"
tell process "Drafts"
-- insert GUI Scripting statements here:
The unix and macos standard is \n and that difference (or a difference in regular expression dialects) might be relevant.
Generally, however, regular expressions are seldom the right place to put any complexity.
A good rule of thumb is that once a regular expression is no longer readable at a glance, or has grown beyond 3-5 semantic units, it is probably not the right tool for the job.
If you are going to invest time in learning a formal language, you might get better value from something that is less restricted, and is readable as well as writable, like Python or JavaScript.
They will let you stick to the useful kind of regular expression, which is always a very simple one.