all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* regex search and replace
@ 2006-10-22 21:12 Gary Wessle
  2006-10-22 21:45 ` Gary Wessle
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Gary Wessle @ 2006-10-22 21:12 UTC (permalink / raw)



Hi

I am using GNU emacs 21.4.1 and wanting to use regex to do the
following.

I have few lines in the format 
  -rw-r--r-- 1 fred fred 56823 Oct 14 01:32 samcar
  ...
  -rw-r--r-- 1 fred fred 56823 Oct 14 01:32 manham

I want to end up with 
{ "sam/car", ..., "man/ham" }

so my step by step approach is to remove the 
"  -rw-r--r-- 1 fred fred 56823 Oct 14 01:32 "

then to change aaabbb with aaa/bbb.

then to replace end of line with (", ")

and maybe by then I will learn enough to finish the task.

so, playing around with	incremental regex search and hoping some body
will help me to learn something mean while.

thanks

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: regex search and replace
  2006-10-22 21:12 regex search and replace Gary Wessle
@ 2006-10-22 21:45 ` Gary Wessle
  2006-10-22 23:24   ` Peter Dyballa
  2006-10-24 15:37   ` rgb
  2006-10-22 22:08 ` Alexis Roda
  2006-10-23 13:29 ` aartist
  2 siblings, 2 replies; 6+ messages in thread
From: Gary Wessle @ 2006-10-22 21:45 UTC (permalink / raw)


Gary Wessle <phddas@yahoo.com> writes:

> Hi
> 
> I am using GNU emacs 21.4.1 and wanting to use regex to do the
> following.
> 
> I have few lines in the format 
>   -rw-r--r-- 1 fred fred 56823 Oct 14 01:32 samcar
>   ...
>   -rw-r--r-- 1 fred fred 56823 Oct 14 01:32 manham
> 
> I want to end up with 
> { "sam/car", ..., "man/ham" }
> 
> so my step by step approach is to remove the 
> "  -rw-r--r-- 1 fred fred 56823 Oct 14 01:32 "
> 
> then to change aaabbb with aaa/bbb.
> 
> then to replace end of line with (", ")
> 
> and maybe by then I will learn enough to finish the task.
> 
> so, playing around with	incremental regex search and hoping some body
> will help me to learn something mean while.
> 
> thanks


I was able to reach 
xxx/yyy
.../...
ass/bbb

but when I replace end-of-line with (", ") it still leaves an
end-of-line after (", ").
that is it does not convert the lines to one lone line in the form
xxx/yyy, ...,"aaa/bbb"

the command I used was
replace-regex<ret>$<ret>", "<ret>

thanks

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: regex search and replace
  2006-10-22 21:12 regex search and replace Gary Wessle
  2006-10-22 21:45 ` Gary Wessle
@ 2006-10-22 22:08 ` Alexis Roda
  2006-10-23 13:29 ` aartist
  2 siblings, 0 replies; 6+ messages in thread
From: Alexis Roda @ 2006-10-22 22:08 UTC (permalink / raw)


En/na Gary Wessle ha escrit:
> Hi
> 
> I am using GNU emacs 21.4.1 and wanting to use regex to do the
> following.
> 
> I have few lines in the format 
>   -rw-r--r-- 1 fred fred 56823 Oct 14 01:32 samcar
>   ...
>   -rw-r--r-- 1 fred fred 56823 Oct 14 01:32 manham
> 
> I want to end up with 
> { "sam/car", ..., "man/ham" }
> 
> so my step by step approach is to remove the 
> "  -rw-r--r-- 1 fred fred 56823 Oct 14 01:32 "
> 
> then to change aaabbb with aaa/bbb.

M-x replace-regexp RET ^.*\(\w\{3\}\)\(\w\{3\}\)$ RET "\1/\2" RET

You can find more info on REs here:

http://www.gnu.org/software/emacs/manual/html_node/Regexps.html#Regexps

> then to replace end of line with (", ")

M-x replace RET C-q C-j RET ,<SPC> RET




HTH

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: regex search and replace
  2006-10-22 21:45 ` Gary Wessle
@ 2006-10-22 23:24   ` Peter Dyballa
  2006-10-24 15:37   ` rgb
  1 sibling, 0 replies; 6+ messages in thread
From: Peter Dyballa @ 2006-10-22 23:24 UTC (permalink / raw)
  Cc: help-gnu-emacs


Am 22.10.2006 um 23:45 schrieb Gary Wessle:

> but when I replace end-of-line with (", ") it still leaves an
> end-of-line after (", ").

EOL is no regular character. You can address it either by this, or by  
C-j.

--
Greetings

   Pete

What’s the difference between OS X and Vista?

Microsoft employees are excited about OS X…

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: regex search and replace
  2006-10-22 21:12 regex search and replace Gary Wessle
  2006-10-22 21:45 ` Gary Wessle
  2006-10-22 22:08 ` Alexis Roda
@ 2006-10-23 13:29 ` aartist
  2 siblings, 0 replies; 6+ messages in thread
From: aartist @ 2006-10-23 13:29 UTC (permalink / raw)


May be you can use Macro. It could be faster to build , compared to
searching or building regexp.
Gary Wessle wrote:
> Hi
>
> I am using GNU emacs 21.4.1 and wanting to use regex to do the
> following.
>
> I have few lines in the format
>   -rw-r--r-- 1 fred fred 56823 Oct 14 01:32 samcar
>   ...
>   -rw-r--r-- 1 fred fred 56823 Oct 14 01:32 manham
>
> I want to end up with
> { "sam/car", ..., "man/ham" }
>
> so my step by step approach is to remove the
> "  -rw-r--r-- 1 fred fred 56823 Oct 14 01:32 "
>
> then to change aaabbb with aaa/bbb.
>
> then to replace end of line with (", ")
>
> and maybe by then I will learn enough to finish the task.
>
> so, playing around with	incremental regex search and hoping some body
> will help me to learn something mean while.
> 
> thanks

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: regex search and replace
  2006-10-22 21:45 ` Gary Wessle
  2006-10-22 23:24   ` Peter Dyballa
@ 2006-10-24 15:37   ` rgb
  1 sibling, 0 replies; 6+ messages in thread
From: rgb @ 2006-10-24 15:37 UTC (permalink / raw)



> but when I replace end-of-line with (", ") it still leaves an
> end-of-line after (", ").
> that is it does not convert the lines to one lone line in the form
> xxx/yyy, ...,"aaa/bbb"
>
> the command I used was
> replace-regex<ret>$<ret>", "<ret>

Use this insted:

replace-regex<ret>C-q C-j<ret>", "<ret>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-10-24 15:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-22 21:12 regex search and replace Gary Wessle
2006-10-22 21:45 ` Gary Wessle
2006-10-22 23:24   ` Peter Dyballa
2006-10-24 15:37   ` rgb
2006-10-22 22:08 ` Alexis Roda
2006-10-23 13:29 ` aartist

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.