On 4/15/17 at 7:23 AM, [email protected] (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]*$)"

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 more spaces/tabs at both the start and end of lines.

HTH


On 4/15/17 at 5:44 AM, [email protected] (Jean-Christophe Helary) 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
--

- Bruce

_bruce__van_allen__santa_cruz__ca_

--

  - Bruce

_bruce__van_allen__santa_cruz__ca_

--
This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email
"[email protected]" 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to