Search and Replace in a text.

Dong Ge harddong at 21cn.net
Fri Oct 1 04:46:20 EDT 2004


Thanks for your reply.

First, I need find the the "Layer:" tag in the orginal text file, then
copy fllowing text string until the new line beginning ( The first
text string is "TV-Frame" in the "Text 1".). 

Second, I need find the "Attr:" tag fllowing the previous "Layer:"
tag, and replace the text string next to the "Attr:" tag with the
content in clipboard.

Third, finding the next "Layer:" tag and repeat the first step and
second step until the end of file.

A lot of thanks again!
----
Dong Ge
2004.10.01

Text 1:
...
Layer: Tv-Frame
Flags: 0x0
Attr: 1
Focus Point: 0 0 0
Layer: Tv-pic
Flags: 0x2300
Attr: 1
Focus Point: 0 0 0
Layer: Tv-shell
Flags: 0x0
Attr: 1
Focus Point: 0 0 0
...

Text 2:
...
Layer: Tv-Frame
Flags: 0x0
Attr: Tv-Frame
Focus Point: 0 0 0
Layer: Tv-pic
Flags: 0x2300
Attr: Tv-pic
Focus Point: 0 0 0
Layer: Tv-shell
Flags: 0x0
Attr: Tv-shell
Focus Point: 0 0 0


On Fri, 01 Oct 2004 09:23:13 +0100, Michael Hoffman
<m.h.3.9.1.without.dots.at.cam.ac.uk at example.com> wrote:

>Dong Ge wrote:
>
>> I'm a new beginner of Python. I want to convet  "Text 1" to "Text 2"
>> below. How to do it?
>
>Sorry, you're going to have to describe your problem a little more fully 
>before I can help you. Otherwise I can only guess.




More information about the Python-list mailing list