delete/backspace grep?

1,086 views
Skip to first unread message

josh

unread,
Nov 21, 2010, 9:31:31 AM11/21/10
to TextWrangler Talk
Hey - Was looking through the manual and i can't seem to find what the
grep is for delete or backspace
for example i have a comma (,) i want to tell it to push all the
comma's in the document back one space
Thanks so much

josh

unread,
Nov 21, 2010, 11:00:12 AM11/21/10
to TextWrangler Talk
Well actually I should say that I would like to move any line that has
a comma back one space to the previous line (not just the comma by
itself but the entire line with the comma)

Thomas Humiston

unread,
Nov 21, 2010, 12:37:48 PM11/21/10
to textwr...@googlegroups.com
There is no grep for backspace or delete. What you do is write a pattern that matches the thing you're looking for as well as the thing you want to delete. Then you write a replacement pattern that *doesn't* include the thing you want to delete.

josh

unread,
Nov 21, 2010, 3:04:49 PM11/21/10
to TextWrangler Talk
What would be a grep to put any line with a comma moved up to the line
above it?
for ex:
john...@aol.com
,76f775527e645bee6157cc75bc1c571b

to be:
john...@aol.com, 76f775527e645bee6157cc75bc1c571b

Thanks in advance!!

Roy McCoy

unread,
Nov 21, 2010, 3:09:03 PM11/21/10
to textwr...@googlegroups.com
You don't need GREP if the comma's always at the beginning of the line,
just \r, > ,[space].

Roy

josh

unread,
Nov 21, 2010, 5:34:50 PM11/21/10
to TextWrangler Talk
where do i insert that?

On Nov 21, 3:09 pm, Roy McCoy <roymccoy...@gmail.com> wrote:
> You don't need GREP if the comma's always at the beginning of the line,
> just \r, > ,[space].
>
> Roy
>
> On Nov 21, 2010, at 9:04 PM, josh wrote:
>
> > What would be a grep to put any line with a comma moved up to the line
> > above it?
> > for ex:
> > johnj...@aol.com
> > ,76f775527e645bee6157cc75bc1c571b
>
> > to be:
> > johnj...@aol.com, 76f775527e645bee6157cc75bc1c571b
>
> > Thanks in advance!!

Thomas Humiston

unread,
Nov 21, 2010, 7:12:20 PM11/21/10
to textwr...@googlegroups.com
When you choose 'Find...' from the Search menu, you will see two boxes, labeled 'Search for' and 'Replace with'. If the 'Use Grep' box is checked, then you can search for \r and it will find every line break character.

The line break character is invisible. But it's what you want to find and remove, because that character is what causes your text to be on two lines instead of one.

Based on your example, it looks like you want to find every line break that is followed by a comma, and replace it with a comma plus a space.

So search for '\r,' (backslash-r followed by a comma, without the quotes).

And replace it with ', ' (a comma and a space, without the quotes).

Until you actually play around and try it, I don't think I can help you any further.

josh

unread,
Nov 21, 2010, 7:54:36 PM11/21/10
to TextWrangler Talk
Thanks! Still learning the ropes but getting the hang of stuff.
Appreciate all the help - was a big boost for me! :)

Roy McCoy

unread,
Nov 21, 2010, 6:54:09 PM11/21/10
to textwr...@googlegroups.com
Josh,

Your example has a line with an e-mail address, followed by
a line beginning with a period followed immediately by code.
You apparently want to convert that to a single line, with
the comma moved up and a space following the comma. So you
don't need GREP, just a simple text replacement. You put

\r,

in the Find: box of your TextWrangler Find dialog, and

,[space]

(a comma followed by a space) in the Replace: box of the same dialog.
Then just select Replace All.

This is extremely simple and may not cover all your cases of
lines with commas, I don't know.


Roy

Thomas Humiston

unread,
Nov 21, 2010, 10:39:37 PM11/21/10
to textwr...@googlegroups.com
Roy, I had thought that finding things like \t and \r required GREP, because when it's turned off the the syntax is no longer highlighted. Glad to see I was wrong. Thanks for the tip.
Reply all
Reply to author
Forward
0 new messages