Created
April 22, 2010 15:17
-
-
Save jonspeicher/375361 to your computer and use it in GitHub Desktop.
Recursively perform multiline regex substitution in files matching a spec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import re, os | |
SEARCH_PATTERN = '^(\s*)\/>\s*<Platform\s*Name=\"WexEVM \(ARMV4I\)\"\s*\/>\s*$' | |
REPLACE_PATTERN = r'\1/>' | |
pattern = re.compile(SEARCH_PATTERN, re.MULTILINE) | |
for (dirpath, dirnames, filenames) in os.walk('.'): | |
for filename in filenames: | |
if re.search('\.vcproj$', filename): | |
fullname = dirpath + '/' + filename | |
text = re.sub(pattern, REPLACE_PATTERN, file(fullname).read()) | |
file(fullname, 'w').write(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment