regex - regular expression for cpp_source files and c_source_files in python -
can tell me how express regular expression following 2 strings:
c_source_files cpp_source_files
i analyze text file contains text segments beginning mentioned strings.
it expressed approximately follows:
for result in re.findall('c(.*?)pp_source_files', re.s) # something....
thx in advance!
you can use regex:
# 'c' optionally followed 'pp', followed '_source_files' r'c(pp)?_source_files'
if need these strings separate words (so things notc_source_files
don't match), can use word boundary 'matchers':
# \b matches word boundary r'\bc(pp)?_source_files\b'
Comments
Post a Comment