On 4 Sep 2003 09:35:18 -0700, rumours say that
sj****@ingr.com (Sunit
Joshi) might have written:
Hello All
I have a problem here where I need to find the drive letters in a text
file and replace them with another letter. Now the lines can be as
long as this
6 'C:\pds\bddin64 \report\mto\' 'SJOSHI'
'D:\pds\bddin6 4\report\format \' 'SJOSHI'
with multiple entries for path; i.e. there may be 2, as above or 1 or
more then 2. If I use the expression .*'([A-Z]:).*?', it only matches
the 2nd D: How do I get all the path groups ..??
I assume that the drive letters will be directly after a single quote.
You need this re:
reDriveLetter = re.compile(r"(? <=')[A-Z](?=:\\)").
You can try reDriveLetter.f indall() or the reDriveLetter.f inditer()
functions then, each match object will match a single capital letter.
Very important to everyone working with regular expressions: the
redemo.py script. Search for a Scripts directory in your python
directories (it's under Tools on Windows, otherwise get it from the
source distribution), redemo.py is in there along with other useful
scripts.
--
TZOTZIOY, I speak England very best,
Microsoft Security Alert: the Matrix began as open source.