tell application "BBEdit" activate mark text 1 of active document of text window 1 options {searching for:"\\bpackage\\s+([a-zA-Z:0-9_]+)\\s*;", using:"\\1", clearing existing:true} mark text 1 of active document of text window 1 options {searching for:"\\bsub\\s+([a-zA-Z0-9_]+)\\s*(?:\\([^)]\\)\\s*)?{", using:" \\1", clearing existing:false} end tell