github.com/nextlinux/gosbom@v0.81.1-0.20230627115839-1ff50c281391/gosbom/formats/common/spdxhelpers/spdxid.go (about)

     1  package spdxhelpers
     2  
     3  import (
     4  	"regexp"
     5  )
     6  
     7  var expr = regexp.MustCompile("[^a-zA-Z0-9.-]")
     8  
     9  // SPDX spec says SPDXID must be:
    10  // "SPDXRef-"[idstring] where [idstring] is a unique string containing letters, numbers, ., and/or -
    11  func SanitizeElementID(id string) string {
    12  	return expr.ReplaceAllString(id, "-")
    13  }