[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: regex search and replace
From: |
Alexis Roda |
Subject: |
Re: regex search and replace |
Date: |
Mon, 23 Oct 2006 00:08:09 +0200 |
User-agent: |
Mozilla Thunderbird 1.5.0.5 (X11/20060719) |
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