Hello
I'm completely new to emacs, and I've tried googling to get the answer
to this, but I got nothing.
I want to delete lines from a rtf file. All these lines are based on the
same pattern :
\li0\fi0 \par \b1 TEXT\b0 \par \par
I tried serching regexp \li0\fi0 \par \b1 .\b0 \par \par, but it didn't
work.
Is that to do with the \ ?
I would be so glad if someone could help me with this.
Thanks
Ced
|
|
0
|
|
|
|
Reply
|
Cedric
|
5/2/2005 4:36:47 AM |
|
Cedric Delalande <laurycedNOSPAM@yahooPAS2SPAM.fr> writes:
> Hello
>
> I'm completely new to emacs, and I've tried googling to get the answer
> to this, but I got nothing.
>
> I want to delete lines from a rtf file. All these lines are based on
> the same pattern :
>
> \li0\fi0 \par \b1 TEXT\b0 \par \par
>
> I tried serching regexp \li0\fi0 \par \b1 .\b0 \par \par, but it
> didn't work.
> Is that to do with the \ ?
>
> I would be so glad if someone could help me with this.
Hi Ced, try out
M-x re-builder
for building complex regular expressions.
Be aware that where for interactive use \\ matches a literal
\, while the corresponding string regexp is "\\\\".
C-M-% (query-replace-regexp)
will allow you to do what you want.
The literal . is matched by \., or "\\.".
Best regards,
Adrian
> Thanks
>
> Ced
--
Adrian Aichner
mailto:adrian@xemacs.org
http://www.xemacs.org/
|
|
0
|
|
|
|
Reply
|
Adrian
|
5/2/2005 6:57:23 AM
|
|
Adrian Aichner a �crit :
> Cedric Delalande <laurycedNOSPAM@yahooPAS2SPAM.fr> writes:
>>I want to delete lines from a rtf file. All these lines are based on
>>the same pattern :
>>
>>\li0\fi0 \par \b1 TEXT\b0 \par \par
> Hi Ced, try out
> M-x re-builder
> for building complex regular expressions.
>
> Be aware that where for interactive use \\ matches a literal
> \, while the corresponding string regexp is "\\\\".
>
> C-M-% (query-replace-regexp)
> will allow you to do what you want.
>
> The literal . is matched by \., or "\\.".
>
Does it mean it shoul look like
\\li0\\fi0 \\par \\b1 .\\b0 \\par \\par
???
Ced
|
|
0
|
|
|
|
Reply
|
Cedric
|
5/2/2005 10:13:42 AM
|
|
Cedric Delalande <laurycedNOSPAM@yahooPAS2SPAM.fr> writes:
> Hello
>
> I'm completely new to emacs, and I've tried googling to get the answer
> to this, but I got nothing.
>
> I want to delete lines from a rtf file. All these lines are based on
> the same pattern :
>
> \li0\fi0 \par \b1 TEXT\b0 \par \par
Hi again, here is a practical approach:
While at the beginning of following line:
\li0\fi0 \par \b1 TEXT\b0 \par \par
press
C-M-s (isearch-forward-regexp)
C-y (yank)
C-s (isearch-forward-exit-minibuffer)
Now access the regexp so created with
C-M-s (isearch-forward-regexp)
M-p (isearch-ring-retreat-edit)
and edit it at will.
E.g. change TEXT to \(.+\) to search for any non-whitespace sequence
of one or more characters.
Copy this regexp and reuse it as the first argument in
C-M-% (query-replace-regexp)
If you use \1 as the second argument, you will replace
\li0\fi0 \par \b1 TEXT\b0 \par \par
with TEXT, where TEXT is non-whitespace sequence of one or more
characters.
Hope this helps,
Adrian
>
> I tried serching regexp \li0\fi0 \par \b1 .\b0 \par \par, but it
> didn't work.
> Is that to do with the \ ?
>
> I would be so glad if someone could help me with this.
> Thanks
>
> Ced
--
Adrian Aichner
mailto:adrian@xemacs.org
http://www.xemacs.org/
|
|
0
|
|
|
|
Reply
|
Adrian
|
5/2/2005 6:31:04 PM
|
|
Thank you for your help.
Now I'd like to erase every blank line in a text file.
I tried with $, with ^, with \n, \r but it didn't work !
I've got this :
Hello
Line 1
Line 2
Line 3
Line 4
and I want :
Hello
Line 1
Line 2
Line 3
Line 4
Can someone give me a tip how to do this.
Ced
Cedric Delalande a �crit :
> Hello
>
> I'm completely new to emacs, and I've tried googling to get the answer
> to this, but I got nothing.
>
> I want to delete lines from a rtf file. All these lines are based on the
> same pattern :
>
> \li0\fi0 \par \b1 TEXT\b0 \par \par
>
> I tried serching regexp \li0\fi0 \par \b1 .\b0 \par \par, but it didn't
> work.
> Is that to do with the \ ?
>
> I would be so glad if someone could help me with this.
> Thanks
>
> Ced
|
|
0
|
|
|
|
Reply
|
Cedric
|
5/3/2005 3:01:21 PM
|
|
> Now I'd like to erase every blank line in a text file.
> I tried with $, with ^, with \n, \r but it didn't work !
>
> I've got this :
>
> Hello
>
> Line 1
> Line 2
>
> Line 3
>
> Line 4
>
> and I want :
>
> Hello
> Line 1
> Line 2
> Line 3
> Line 4
>
> Can someone give me a tip how to do this.
>
If the blank lines are actually empty then this should do it.
M-x flush-lines <RET> ^$ <RET>
If there might be spaces or tabs on the line
then this should match even if whitespace exists.
M-x flush-lines <RET> ^\s-*$ <RET>
|
|
0
|
|
|
|
Reply
|
rgb
|
5/3/2005 4:38:54 PM
|
|
|
5 Replies
403 Views
(page loaded in 0.002 seconds)
Similiar Articles: Search a text and delete the line containing it - comp.emacs ...Hello I'm completely new to emacs, and I've tried googling to get the answer to this, but I got nothing. I want to delete lines from a rtf file. Al... Find word, replace line - comp.lang.awkSearch a text and delete the line containing it - comp.emacs ... Search a text and delete the line containing it - comp.emacs ... Find word, replace line - comp.lang.awk ... Matching certain unicode characters with REGEXP - comp.databases ...The field is of type text collation utf8_roman_ci (or similar). (Of course, I do ... perl + regex bug? - comp.lang.perl.misc... first pattern on the if line is matching ... Finding common lines between text files - comp.unix.programmer ...I have to remove all the bytes from 128 - 255 in my text file ... sed Find ... ... pdf by command line - comp.text ... find page (number) containing a given text - comp.text.pdf ... Find and Replace script, util, etc... - comp.databases.filemaker ...Find word, replace line - comp.lang.awk Find and Replace script, util, etc... - comp ... How can you find and replace text in a file using the Windows ... ... ... How to combine two awk commands - comp.lang.awkSearch a text and delete the line containing it - comp.emacs ... How to combine two awk commands - comp.lang.awk merge two files in awk - comp.lang.awk awk simple script ... finding if string of edit text is empty - comp.soft-sys.matlab ...Delete part of a text string? - comp.databases ... find page (number) containing a given text - comp.text.pdf ... ... cmd line function for Edit->Find Files... - comp.soft ... Delete line above and below the line which matches a pattern ...Hi, I want to search for a specific pattern in a file and delete one line ... pattern from a line - comp.unix.shell ..... lines of text in a ... return the lines containing ... Create staple diagrams from a text file (containing numbers) from ...Hi, From the command line, is it possible to somehow automatically create a staple diagram from a file containing text/numbers and automatically ... cut or delete text in cell - comp.databases.filemakerselect last field of line (cut/sed/awk etc) - comp.unix.shell ..... you advise ... Remove characters from text - Excel - Office.com Remove a text string from a worksheet by ... Search a text and delete the line containing it - comp.emacs ...Hello I'm completely new to emacs, and I've tried googling to get the answer to this, but I got nothing. I want to delete lines from a rtf file. Al... Delete a Line Containing Certain String Or TextIncoming search terms: notepad delete lines containing, notepad delete line, select a line which contains a text notepad, delete line containing string, delete line that ... 7/23/2012 9:39:27 PM
|