I'm not sure whether BBEdit's find/replace can be used in that way. The 
commands normally trigger the find/replace to occur within the specified open 
text document. This command removes all the white space from the beginnings of 
lines in the frontmost document.

tell application "BBEdit"
        activate
        replace "^\\s+" using "" searching in text 1 of text document 1 options 
{search mode:grep, starting at top:true}
end tell

It doesn't look AppleScript has native regular expressions, but you can add 
them using this plug-in.

http://www.satimage.fr/software/en/downloads/downloads_companion_osaxen.html

Hope this helps,

[fletcher]


> On Apr 15, 2017, at 5:44 AM, Jean-Christophe Helary 
> <jean.christophe.hel...@gmail.com> wrote:
> 
> It looks like I'm trying to reinvent the wheel, but I can find a way to do 
> this:
> 
> 1) replace ^\s with nothing
> 2) replace \s$ with nothing
> 
> in a single string
> 
> The following lines don't work, because of the "^":
> 
> set pathstring to "           /path/to/my file.stuff  "
> 
> tell application "BBEdit"
>       replace "^\\s" using "" searchingString pathstring options {search 
> mode:grep}
> end tell
> 
> But when I remove the "^", the space within the path is also removed, which I 
> don't want.
> 
> 
> Also, I find it's too bad the remove prefix/suffix/prefix and suffix don't 
> have a grep option.
> 
> Jean-Christophe 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or would like to report a problem, please email
> "supp...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: <http://www.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 bbedit+unsubscr...@googlegroups.com.
> To post to this group, send email to bbedit@googlegroups.com.
> Visit this group at https://groups.google.com/group/bbedit.

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.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 bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to