Class WordsTrie
java.lang.Object
com.cloudbees.jenkins.support.filter.WordsTrie
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
-
Method Summary
-
Constructor Details
-
WordsTrie
public WordsTrie()
-
-
Method Details
-
add
Add a word to the Trie.- Parameters:
word
- the word
-
getRegex
Get the regex String of this Trie.- Returns:
- the regex String of this Trie.
-