I tried various regexes including the ones mentioned @ Python 3 regular expression to find multiline comment to match my input file given below,complete code is also below.Following is the regex am using currenlty to match the input file @http://pastie.org/5653293
pattern = re.compile(r'/\*.*?'+ needle + '.*?\*/', re.DOTALL)
can someone provide inputs on why the regex is not matching?
import os
import sys
import re
import fnmatch
def find_and_remove(haystack, needle):
re.escape(needle)
pattern = re.compile(r'/\*.*?'+ needle + '.*?\*/', re.DOTALL)
return re.sub(pattern, "", haystack)
for path,dirs,files in os.walk(sys.argv[1]):
for fname in files:
for pat in ['*.cpp','*.c','*.h','*.txt']:
if fnmatch.fnmatch(fname,pat):
fullname = os.path.join(path,fname)
# put all the text into f and read and replace...
f = open(fullname).read()
result = find_and_remove(f, r"Copyright (c) 2012, The Linux Foundation. All rights reserved")
INPUT:- http://pastie.org/5653293