Re: trimming + grep + applescript

2017-04-17 Thread Jean-Christophe Helary
> On Apr 18, 2017, at 1:29, Bruce Van Allen wrote: > > On 4/17/17 at 9:03 AM, t...@me.com (Tom) wrote: > >> To match any whitespace except newlines you can use the Unicode class `\h` > > Yes. I think the OP was only concerned with spacebar spaces, and maybe tabs. Indeed, that's what the OP wa

Re: trimming + grep + applescript

2017-04-17 Thread Bruce Van Allen
On 4/17/17 at 9:03 AM, t...@me.com (Tom) wrote: To match any whitespace except newlines you can use the Unicode class `\h` Yes. I think the OP was only concerned with spacebar spaces, and maybe tabs. Thanks -- - Bruce _bruce__van_allen__santa_cruz__ca_ -- This is the BBEdit Talk public

Re: trimming + grep + applescript

2017-04-17 Thread Tom
On Saturday, April 15, 2017 at 5:03:22 PM UTC+2, Bruce Van Allen wrote: > On 4/15/17 at 7:23 AM, b...@cruzio.com (Bruce Van Allen) > wrote: > That pattern matches zero or more spaces/tabs > > ADDED: It also removes blank lines. If you were concerned > exclusively with spacebar spaces, change

Re: trimming + grep + applescript

2017-04-16 Thread Jean-Christophe Helary
Thank you very much Chris. I'll check this one when I've completed my "scratch window" thing for SD... Jean-Christophe > On Apr 17, 2017, at 7:20, Christopher Stone > wrote: > > On 04/15/2017, at 18:27, Jean-Christophe Helary > mailto:jean.christophe.hel...@gmail.com>> > wrote: >>> This jo

Re: trimming + grep + applescript

2017-04-16 Thread Christopher Stone
On 04/15/2017, at 18:27, Jean-Christophe Helary mailto:jean.christophe.hel...@gmail.com>> wrote: >> This job can also be handled nicely by AppleScriptObjC these days: > > Yeah :) > > This is really ugly :) But I guess that's a place from where I can start > getting things done with ASObj-C...

Re: trimming + grep + applescript

2017-04-15 Thread Jean-Christophe Helary
Thank you all for the replies. > On Apr 16, 2017, at 5:53, Christopher Stone > wrote: > > A) Correct regex syntax (which Bruce kindly provided). Sorry, my regex was indeed about removing stuff at the beginning *only* and since I could not figure how to make that work, I did not add the thing

Re: trimming + grep + applescript

2017-04-15 Thread Christopher Stone
On 04/15/2017, at 07:44, Jean-Christophe Helary mailto: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 Hey Jean-Christophe, The

Re: trimming + grep + applescript

2017-04-15 Thread Bruce Van Allen
On 4/15/17 at 7:23 AM, b...@cruzio.com (Bruce Van Allen) wrote: That pattern matches zero or more spaces/tabs ADDED: It also removes blank lines. If you were concerned exclusively with spacebar spaces, change the pattern to "(^ *| *$)" Or, remove spaces and tabs using "(^[ \t]*|[ \t]*$)"

Re: trimming + grep + applescript

2017-04-15 Thread Fletcher Sandbeck
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"

Re: trimming + grep + applescript

2017-04-15 Thread Bruce Van Allen
Hi, This works over here: tell application "BBEdit" activate set pathstring to "/Users/me/Desktop/testfile.txt" replace "(^\\s*|\\s*$)" using "" searching in text of pathstring options {search mode:grep, starting at top:true, wrap around:true} end tell That pattern matches zero or

trimming + grep + applescript

2017-04-15 Thread Jean-Christophe Helary
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"