Re: [Tutor] Search and replace text in XML file?

2012-07-28 Thread Mark Lawrence
On 28/07/2012 02:38, Todd Tabern wrote: I'm looking to search an entire XML file for specific text and replace that text, while maintaining the structure of the XML file. The text occurs within multiple nodes throughout the file. I basically need to replace every occurrence C:\Program Files wit

Re: [Tutor] Search and replace text in XML file?

2012-07-28 Thread Alan Gauld
On 28/07/12 02:38, Todd Tabern wrote: I'm looking to search an entire XML file for specific text and replace that text, > while maintaining the structure of the XML file. Do you mean the physical layout of the file or the technical XML structure? I'm assuming its the latter? If it's the forme

Re: [Tutor] Search and replace text in XML file?

2012-07-28 Thread Bod Soutar
On Jul 28, 2012 2:39 AM, "Todd Tabern" wrote: > > I'm looking to search an entire XML file for specific text and replace that text, while maintaining the structure of the XML file. The text occurs within multiple nodes throughout the file. > I basically need to replace every occurrence C:\Program

[Tutor] Search and replace text in XML file?

2012-07-27 Thread Todd Tabern
I'm looking to search an entire XML file for specific text and replace that text, while maintaining the structure of the XML file. The text occurs within multiple nodes throughout the file. I basically need to replace every occurrence C:\Program Files with C:\Program Files (x86), regardless of

Re: [Tutor] search and replace

2006-03-07 Thread Danny Yoo
> > Slightly more robust is the '\b' boundary assertion pattern: > > And I never understood why there were two... > > Which begs the question: under what circumstance would we prefer > to use \W instead of \b? In terms of code: ## >>> import re >>> re.search(r'(\W\w+\W)', 'hello|||').gro

Re: [Tutor] search and replace

2006-03-07 Thread Alan Gauld
>> Specifically \W signifies a word boundary so >> > Using the non-word pattern '\W' will work except in cases where we're > right at the edge: Sneaky! I didn't know that... > Slightly more robust is the '\b' boundary assertion pattern: And I never understood why there were two... Which begs th

Re: [Tutor] search and replace

2006-03-07 Thread Danny Yoo
> regex allows us to specify certain conditions in the patterns > such as whether the characters are digits etc, and also whether > we are kooking for a word which is wat you want. > Specifically \W signifies a word boundary so > > \Whello\W > > will find hello as a word. Hi Alan, Using the non-

Re: [Tutor] search and replace

2006-03-07 Thread Alan Gauld
Hi tak, > hello, Othello. # just the hello and not Othello One simplistic approach that does not use regex is to search for spaces as part of the string. But that doesn't work for punctuation nor at the start or end of lines. So that leaves us, as you observed, with regular expressions. regex a

Re: [Tutor] search and replace

2006-03-07 Thread Danny Yoo
> I have a problem finding specific words. > I would like to filter out a word or replace it in a file. > I notices that the re module is good for finding patterns. Hi Tak, Although regular expressions might be overkill for this problem, it can't hurt to know about the Regex HOWTO: http://

[Tutor] search and replace

2006-03-06 Thread tak
Hello, I have a problem finding specific words. I would like to filter out a word or replace it in a file. I notices that the re module is good for finding patterns. I am trying to filter out a word from strings, but having a little trouble. I was wondering if I can search a string for a specific

Re: [Tutor] Search and Replace

2005-06-24 Thread Chad Crabtree
Reed L. O'Brien wrote: >I ma trying to write a script to search adn replace a sizable chink of >text in about 460 html pages. >It is an old form that usesa search engine no linger availabe. > Well in the vein of Kents suggestion there is http://www.crummy.com/software/BeautifulSoup/ however it wi

Re: [Tutor] Search and Replace

2005-06-24 Thread Kent Johnson
Reed L. O'Brien wrote: > I ma trying to write a script to search adn replace a sizable chink of > text in about 460 html pages. > It is an old form that usesa search engine no linger availabe. > > I am wondering if anyone has any advice on the best way to go about that. > There are more than one l

[Tutor] Search and Replace

2005-06-24 Thread Reed L. O'Brien
I ma trying to write a script to search adn replace a sizable chink of text in about 460 html pages. It is an old form that usesa search engine no linger availabe. I am wondering if anyone has any advice on the best way to go about that. There are more than one layout place ment for the form, but