gitlab.com/evatix-go/core@v1.3.55/regexnew/CreateMust.go (about)

     1  package regexnew
     2  
     3  import "regexp"
     4  
     5  // CreateMust creates regex if not already exist in dictionary.
     6  //
     7  // if any error then panics
     8  func CreateMust(regularExpressionSyntax string) *regexp.Regexp {
     9  	regex, has := regexMaps[regularExpressionSyntax]
    10  
    11  	if has {
    12  		return regex
    13  	}
    14  
    15  	newRegex := regexp.MustCompile(regularExpressionSyntax)
    16  	regexMaps[regularExpressionSyntax] = newRegex
    17  
    18  	return newRegex
    19  }