Skip to content

Commit

Permalink
Moved MustCompile to global variable #5
Browse files Browse the repository at this point in the history
  • Loading branch information
Smuzzy-waiii committed Oct 7, 2023
1 parent 8cc0260 commit aaf41e4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions handlers/WebhookHandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ func contains(s []string, str string) bool {
return false
}

const pattern = `^!bounty\s+(\d+)`

var regex = regexp.MustCompile(pattern)

// function to validate if PR bounty comment is in the correct format
// and get bounty points
func parseBountyPoints(comment string) (int, bool) {
comment = strings.TrimLeft(comment, " ")

pattern := `^!bounty\s+(\d+)`
// Compile the regular expression
regex := regexp.MustCompile(pattern)
// Use FindStringSubmatch to search for the pattern in the text
matches := regex.FindStringSubmatch(comment)
//fmt.Println(matches)
Expand Down

0 comments on commit aaf41e4

Please sign in to comment.