Replace unknow string varible in file.

2009-02-10 Thread namire
Hey .python first time poster here. I'm pretty good with python so
far, but I keep needed a function in my program but not knowing how to
build it. =( Here's the problem:

Imagine a html file full of 100's of these strings all mooshed
together onto many lines;
ITEM
Where the word 'MARKER' is a constant, it stay the same in each string
and the word 'ITEM' is a random combination of ascii characters of an
unknown length. So for example a:
CATFISHText text textSPAM and so on...

What I need to do it replace each instance of the random letter with a
constant and/or delete them. The file is a html file so the stuff
inside of  is ok to keep and I need that data to identify
where the strings are in the file (it's full of other stuff too).  I'm
tired making a bruteforcer but with unknown length and 26 letters of
the alphabet I gave up because it would take too long (it was
something like; read file; if '@@MARKER@@; id="'+str(gen_string)+'"--
>"+sr(gen_string)+'' in file then replace with '', but I'm
paraphrasing code and it's not the best solution anyway).

Just as a comparison in the Windows OS this seems easy to do when
managing files, say for the file a-blah-b-blah.tmp where blah is an
unknown you can use: del a-*-b-*.tmp to get rid of that file. But for
python and a string in text file I don't have a clue. @_@ could
someone please help me?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Replace unknow string varible in file.

2009-02-11 Thread namire
Thanks to Vlastimil Brom for his example and r0g for his helpful
attitude and hyperlinks I was able to made program do what was
needed.  Terry the comments in the html are not important I was just
saying that if I could cover the undesired strings in html comment
tags then they would not should up on a web browser viewing the file,
lucky I get then erased also so the comments is not needed.  I anyone
wants I can post a pastebin the the full code that uses the regex's.
--
http://mail.python.org/mailman/listinfo/python-list