I'm trying to find and print the beginning and ending indices of the C keywords inside the string
code = 'int main( void )\n{\nreturn 0;\n}'
Here's what I have so far:
pattern = '/\bint|void|return\b/'
temp = re.compile( pattern )
for result in temp.finditer( code ):
print 'Found %s from %d to %d.' % ( result.group(), result.start(), result.end() )
However, only 'void' is being found. Why is that?
int <something> return <something>;why not simply match the string ?code.find('int ')...