473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Search and Replace in a text.

I'm a new beginner of Python. I want to convet "Text 1" to "Text 2"
below. How to do it?

__
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
Jul 18 '05 #1
2 1411
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.
--
Michael Hoffman
Jul 18 '05 #2
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.*********************************@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.


Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Les Juby | last post by:
A year or two back I needed a search script to scan thru HTML files on a client site. Usual sorta thing. A quick search turned up a neat script that provided great search results. It was fast,...
22
by: Phlip | last post by:
C++ers: Here's an open ended STL question. What's the smarmiest most templated way to use <string>, <algorithms> etc. to turn this: " able search baker search charlie " into this: " able...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
6
by: DataSmash | last post by:
Hello, I need to search and replace 4 words in a text file. Below is my attempt at it, but this code appends a copy of the text file within itself 4 times. Can someone help me out. Thanks! #...
2
by: Ola K | last post by:
Hi guys, I wrote a script that works *almost* perfectly, and this lack of perfection simply puzzles me. I simply cannot point the whys, so any help on it will be appreciated. I paste it all here,...
0
by: | last post by:
I have a question about spawning and displaying subordinate list controls within a list control. I'm also interested in feedback about the design of my search application. Lots of code is at the...
9
by: tomjones75 | last post by:
dear community, i want to search the content of all fields in one table in a access database. it already works for the content of one field in the table. please take a look at the code in...
1
by: coolami4u | last post by:
I need a program that simulates the search-and-replace operation in a text editor. The program is to have only three function calls in main. The first function prompts the user to type a string of...
1
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and...
5
by: silmana | last post by:
Hi i have this script that i want to use as php or html but i cant find the problem, could anyone solve the problem, i dont know why i cannot use it in php or html file // OBS! Några saker måste...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.