Fuzzy mactch regex


I’m wondering if the RegEx tools included in hugo have a “Approximate matching settings”, where basically one can say “match within a levinstein distance of x”. Something like the {~} operator in TRE regex TRE Regex Syntax Manual
I don’t think they do as I would suspect that they rely on golang’s RE2 module or something similar… I just wanted to get some confirmation.

My use case is that I wanted to, as part of my theme, run at compile time, a check for similar terms in each of my taxonomies. (I know about the singular and pluralize functions, but they don’t help catch inverted letters like die, dei. ).

Hugo uses Go’s Regular Expression package, which is the same general syntax used by Perl, Python, and other languages but with a few minor differences for those coming from a background in PCRE. For a full syntax listing, see the GitHub wiki for re2.

If you are just learning RegEx, or at least Go’s flavor, you can practice pattern matching in the browser at https://regex101.com/.

1 Like