package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)((@[\w\d][\w\d_]+)\s+)?(\.[\w\d][\w\d_]+\s+)`)
var str = `@array .byte 3, 4, 23
va1 .byte 'A', -3, 0xAB // Three bytes
@str1 .byte "Enter an integer: " // Null-terminated string
@var2 .hword 0xABCD:10 // 0xABCD is replicated 10 times
@var3 .word -18, 5.7E-3 // 4-byte integer, single float
@var4 .dword 21, 21.0 // 8-byte integer, double float
//Assembly Language Syntax:
J @label // Jump @label
JAL @label // R31 = (PC+4); Jump @label
The JAL instruction saves the return address `
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/