77 "strconv"
88 "strings"
99
10- "github.com/errata-ai/regexp2 "
10+ rx "github.com/errata-ai/vale/v3/internal/regex "
1111 "github.com/mitchellh/mapstructure"
1212 "gopkg.in/yaml.v3"
1313
@@ -334,14 +334,14 @@ func matchToken(expected, observed string, ignorecase bool) bool {
334334 p = ignoreCase + p
335335 }
336336
337- r , err := regexp2 . CompileStd (fmt .Sprintf (tokenTemplate , p ))
337+ r , err := rx . Compile (fmt .Sprintf (tokenTemplate , p ))
338338 if core .IsPhrase (expected ) || err != nil {
339339 return expected == observed
340340 }
341341 return r .MatchStringStd (observed )
342342}
343343
344- func updateExceptions (previous []string , current []string , vocab bool ) (* regexp2 .Regexp , error ) {
344+ func updateExceptions (previous []string , current []string , vocab bool ) (* rx .Regexp , error ) {
345345 if vocab {
346346 previous = append (previous , current ... )
347347 }
@@ -369,10 +369,10 @@ func updateExceptions(previous []string, current []string, vocab bool) (*regexp2
369369
370370 regex = fmt .Sprintf (regex , strings .Join (previous , "|" ))
371371 if len (previous ) > 0 {
372- return regexp2 . CompileStd (regex )
372+ return rx . Compile (regex )
373373 }
374374
375- return & regexp2 .Regexp {}, nil
375+ return & rx .Regexp {}, nil
376376}
377377
378378// buildPhraseRe compiles a regex matching the multi-word entries among the
@@ -383,7 +383,7 @@ func updateExceptions(previous []string, current []string, vocab bool) (*regexp2
383383//
384384// Returns nil when there are no multi-word terms (or one fails to compile, in
385385// which case `updateExceptions` surfaces the error).
386- func buildPhraseRe (previous , current []string , vocab bool ) * regexp2 .Regexp {
386+ func buildPhraseRe (previous , current []string , vocab bool ) * rx .Regexp {
387387 terms := append ([]string {}, previous ... )
388388 if vocab {
389389 terms = append (terms , current ... )
@@ -400,7 +400,7 @@ func buildPhraseRe(previous, current []string, vocab bool) *regexp2.Regexp {
400400 return nil
401401 }
402402
403- re , err := regexp2 . CompileStd (ignoreCase + `\b(?:` + strings .Join (phrases , "|" ) + `)\b` )
403+ re , err := rx . Compile (ignoreCase + `\b(?:` + strings .Join (phrases , "|" ) + `)\b` )
404404 if err != nil {
405405 return nil
406406 }
@@ -410,7 +410,7 @@ func buildPhraseRe(previous, current []string, vocab bool) *regexp2.Regexp {
410410// withinPhrase reports whether the span `loc` falls entirely within a match of
411411// `phraseRe` (an accepted multi-word phrase) in `txt`. Both `loc` and the
412412// phrase spans are rune offsets, as returned by regexp2's FindAllStringIndex.
413- func withinPhrase (phraseRe * regexp2 .Regexp , txt string , loc []int ) bool {
413+ func withinPhrase (phraseRe * rx .Regexp , txt string , loc []int ) bool {
414414 if phraseRe == nil {
415415 return false
416416 }
0 commit comments