package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?ms)^\s*\/\*.*?\*\/`)
var str = `/**
* base comment
* (c) SOMEBODY SOMETIME
* something
*/
///<!-- ------metadata-XML------- -->
/// <module type="javascript"> A
///<desc> some desc
/// </desc>
(function( a /* param A */) { // programmers comment ... enclosure
/*! user doc
this module ....
* reguired
.....
*/
var b={}; // programmers in line comment
// single line comments
// The cookie spec says up to 4k per cookie, so at ~50 bytes per entry
// that gives a maximum of around 80 items as a max value for this field
b.a=a;
var str = " tttt //this is not comment ! tttt "
var str2 = " tttt /* this is not comment too ! \
.............. */ ttt ";
global.b = b;
}(global);
///</module>`
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/