# TIP: translate FORTRAN array to C

I am really bored to convert the FORTRAN array decorator () to C array [], and eventually, I hacked this small script to do the tedious work:

import sys, re, string
p = re.compile( '([A-Z]+)$$([^\($$]+)\)' )
for line in sys.stdin:
print string.rstrip( p.sub( r'\1[\2]', line ))+";"

Here is the trick: the array consists variable name(capitalized letters), (, whatever, ). we group the variable name and whatever as group 1, 2; then replace (, ) with [, ]. A simple demonstration of how powerful the regular expression is.