package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)((RESERVADAS|[A-Z]+)[(][)][ ]*[\t]*[\r\n|\n]*([{][\r\n|\n]*([\t]*[ ]*[0-9]+[ ]*[=][ ]*(['][A-Z]+['])[\r\n|\n]*)+[\r\n|\n]*[}][\r\n|\n]*)*)`)
var str = `RESERVADAS()
{
18 = 'PROGRAM'
19 = 'INCLUDE'
20 = 'CONST'
21 = 'TYPE'
22 = 'VAR'
23 = 'RECORD'
24 = 'ARRAY'
25 = 'OF'
26 = 'PROCEDURE'
27 = 'FUNCTION'
28 = 'IF'
29 = 'THEN'
30 = 'ELSE'
31 = 'FOR'
32 = 'TO'
33 = 'WHILE'
34 = 'DO'
35 = 'EXIT'
36 = 'END'
37 = 'CASE'
38 = 'BREAK'
39 = 'DOWNTO'
}
COSO()
{
19='A'
}
`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/