Documentation ¶
Index ¶
- func AllSimpleFold(input rune) []rune
- func Contains(elements []string, needle string) bool
- func Fuzz(data []byte) int
- func HighlightString(content string, locations [][]int, in string, out string) string
- func IndexAll(haystack string, needle string, limit int) [][]int
- func IndexAllIgnoreCase(haystack string, needle string, limit int) [][]int
- func IsSpace(firstByte, nextByte byte) bool
- func PermuteCase(input string) []string
- func PermuteCaseFolding(input string) []string
- func RemoveStringDuplicates(elements []string) []string
- func StartOfRune(b byte) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllSimpleFold ¶
Given an input rune return a rune slice containing all of the possible simple fold
func Fuzz ¶
For fuzz testing... https://github.com/dvyukov/go-fuzz install both go-fuzz-build and go-fuzz go-fuzz-build && go-fuzz
func HighlightString ¶
HighlightString takes in some content and locations and then inserts in/out strings which can be used for highlighting around matching terms. For example you could pass in "test" and have it return "<strong>te</strong>st" locations accepts output from regex.FindAllIndex IndexAllIgnoreCase or IndexAll
func IndexAll ¶
IndexAll extracts all of the locations of a str inside another str up-to the defined limit and does so without regular expressions which makes it faster than FindAllIndex in most situations while not being any slower. It performs worst when working against random data.
Some benchmark results to illustrate the point (find more in index_benchmark_test.go)
BenchmarkFindAllIndex-8 2458844 480.0 ns/op BenchmarkIndexAll-8 14819680 79.6 ns/op
For pure literal searches IE no regular expression logic this method is a drop in replacement for re.FindAllIndex but generally much faster.
Similar to how FindAllIndex the limit option can be passed -1 to get all matches.
Note that this method is explicitly case sensitive in its matching. A return value of nil indicates no match.
func IndexAllIgnoreCase ¶
IndexAllIgnoreCase extracts all of the locations of a str inside another str up-to the defined limit. It is designed to be faster than uses of FindAllIndex with case insensitive matching enabled, by looking for str literals first and then checking for exact matches. It also does so in a unicode aware way such that a search for S will search for S s and ſ which a simple strings.ToLower over the haystack and the needle will not.
The result is the ability to search for literals without hitting the regex engine which can at times be horribly slow. This by contrast is much faster. See index_ignorecase_benchmark_test.go for some head to head results. Generally so long as we aren't dealing with random data this method should be considerably faster (in some cases thousands of times) or just as fast. Of course it cannot do regular expressions, but that's fine.
For pure literal searches IE no regular expression logic this method is a drop in replacement for re.FindAllIndex but generally much faster.
func IsSpace ¶
Bytes MUST be UTF-8 encoded List of spaces detected (same as unicode.IsSpace): '\t', '\n', '\v', '\f', '\r', ' ', U+0085 (NEL), U+00A0 (NBSP). N.B only two bytes are required for these cases. If we decided to support spaces like ',' then we'll need more bytes.
func PermuteCase ¶
Given a str returns a slice containing all possible case permutations of that str such that input of foo will return foo Foo fOo FOo foO FoO fOO FOO Note that very long inputs can produce an enormous amount of results in the returned slice OR result in an overflow and return nothing
func PermuteCaseFolding ¶
Given a str returns a slice containing all possible case permutations with characters being folded such that S will return S s ſ
func RemoveStringDuplicates ¶
Simple helper method that removes duplicates from any given str slice and then returns a nice duplicate free str slice
func StartOfRune ¶
Checks a byte and returns true if its the start of a multibyte character or a single byte character otherwise false
Types ¶
This section is empty.