Here's one way to do that:
- copy&paste your file's content to a new buffer.
- in the new buffer do
C-u C-s ^[^,]*,'\([^']*\)',.* M-% \1 RET !
.
문제
I would like to find/extract a group in each line of a buffer, then write it to a new buffer.
So in my comma-delimted data file, my lines basically look like this:
'A-field','B-field','C-field','D-field'
i.e., four single-quoted fields of data per line. I want to extract the quoted B-field and write it to a new buffer.
Is it possible at the elisp repl to extract from one buffer and write that to a new buffer? Or is this something you'd write as a stand-alone .el file then call from the buffer (M-my-extract-write) from the mini-buffer?
해결책
Here's one way to do that:
C-u C-s ^[^,]*,'\([^']*\)',.* M-% \1 RET !
.다른 팁
I recommend multiple-cursors + sexp movements for stuff like this.
Macros also work well, but the immediate feedback of multiple-cursors is nice.
Writing elisp to handle simple repetitive tasks is overkill.