package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?<!#)(?:(?<=_FILE).+"(.+)")`)
var str = `# ---------------------------------------------------------------------------- #
# Packages
# ---------------------------------------------------------------------------- #
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "file_1_test_1_qip.vhd"]
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "file_2_test_1_qip.vhd"]
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "file_3_test_1_qip.vhd"]
# Register Tool set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "file_INVALID_test_1_qip.vhd"]
# ---------------------------------------------------------------------------- #
# Sub Modules
# ---------------------------------------------------------------------------- #
set_global_assignment -name QIP_FILE [file join $::quartus(qip_path) "module_test_2.qip"]
set_global_assignment -name QIP_FILE [file join $::quartus(qip_path) "module_test_3.qip"]
# ---------------------------------------------------------------------------- #
# Module Files
# ---------------------------------------------------------------------------- #
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "file_4_test_1_qip.vhd"]
set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "file_5_test_1_qip.vhd"]`
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/