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

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -