package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)(?:(\bclass)(?:[:]([_a-zA-Z0-9-]+))?\s*[=]?(?:[{}]{0,}['"\s]*\b(.+)?\b["'\s]*[{}]*)?)|(?:\B([@]apply)\s+([_a-zA-Z0-9-\s\:\/]*)[;]?)`)
var str = `<SvelteComponent class:active={true} />
<img src="..." class="image" />
<div class="@apply bg-gray-500 px-10 py-5;">
class:active={is_active ? true : false}
class="mb-0 font-semibold text-white" `
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/