I would like to extract characters from Fortran codes in Ruby. Symbols will have the following patterns (NOTE: the type of the variable and parts of the attribute are filtered):
a = b, c(2) ! Match result should be "a" and "c" d(3) = [1,2, & ! Match result should be "d" 3]
The regex I tried, ((?<!=)\w+(?![^\[]*\]+)(?=( |,|\(|$))) With lookaround stuffs. But because lookbehind restrictions i can't match "= *" to exclude b .
I used Rubular for testing. For your convenience see here .
Thanks in advance!
source share