Class WordsTrie
- java.lang.Object
-
- com.cloudbees.jenkins.support.filter.WordsTrie
-
public class WordsTrie extends Object
Trie implementation to generate a "Trie regex". A regex that reduces backtracking by following a Trie structure.When searching for a match within a list of words, for example
["go", "goes", "going", "gone", "goose"]
, a simple regex that matches any word would typically look like\b(?:(go|goes|going|gone|goose))\b
.While this works, Such a pattern can be optimized significantly by following a Trie structure in the prefixes such as
\b(?:go(?:(?:es|ing|ne|ose))?)\b
.
-
-
Constructor Summary
Constructors Constructor Description WordsTrie()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(String word)
Add a word to the Trie.String
getRegex()
Get the regex String of this Trie.
-