trying to find a substring in a string

barnacle.steve at gmail.com barnacle.steve at gmail.com
Sun Jun 22 00:52:05 CEST 2008


I'm trying to write what should be a simple script in Python, which
I've never ever used before.

Essentially, I have a text file that has a list of full path file
names to other files, separated by carriage returns.
Contents of first file:
c:\blah.txt
c:\blah1.txt
c:\blah2.txt

The goal is for the user to specify another file, and then search the
specified file for instances of files from the first file.
Contents of user specified file:
file = "c:\blah.txt"
file = "c:\blah1.txt"

My goal is for the program to tell me that it found c:\blah.txt and c:
\blah1.txt.

I've read the contents of the existing file into an array, where each
element is a line from the file. I did the same thing with the user
specified file. I thought it would be a simple nested for loop to find
them, but I'm having no luck finding the strings. The string find
method doesn't do it for me. I've tried regular expressions, but it
never finds a match. I think it doesn't like when I do
re.compile(variableName), but without a debugger I have no way to tell
what's going on at all.

I keep telling myself this should be really simple, but I'm ready to
jump out a window.

Any help would be greatly appreciated. Thanks in advance.



More information about the Python-list mailing list