Select Git revision
string_utils_test.go
-
Johan de Klerk authoredJohan de Klerk authored
string_utils.go 8.65 KiB
package string_utils
import (
"bytes"
"encoding/json"
"fmt"
"github.com/samber/lo"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/number_utils"
"regexp"
"strconv"
"strings"
"unicode"
"github.com/thoas/go-funk"
"golang.org/x/text/runes"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
)
const (
snakeCasePattern = `[a-z]([a-z0-9_]*[a-z0-9])*`
regexIndexMatchStart = 0
regexIndexMatchEnd = 1
regexIndexSubmatchStart = 2
regexIndexSubmatchEnd = 3
)
var WhitespaceChars = []string{
// Standard whitespace characters
"\u0009", // Character tabulation
"\u000A", // Line feed
"\u000B", // Line tabulation
"\u000C", // Form feed
"\u000D", // Carriage return
"\u0020", // Space
"\u0085", // Next line
"\u00A0", // No-break space
"\u1680", // Ogham space mark
"\u2000", // En quad
"\u2001", // Em quad
"\u2002", // En space
"\u2003", // Em space
"\u2004", // Three-per-em space
"\u2005", // Four-per-em space
"\u2006", // Six-per-em space
"\u2007", // Figure space
"\u2008", // Punctuation space
"\u2009", // Thin space
"\u200A", // Hair space
"\u2028", // Line separator
"\u2029", // Paragraph separator
"\u202F", // Narrow no-break space
"\u205F", // Medium mathematical space
"\u3000", // Ideographic space
}
var NonOfficialWhitespaceChars = []string{
// Characters with property White_Space=no
"\u180E", // Mongolian vowel separator
"\u200B", // Zero width space
"\u200C", // Zero width non-joiner
"\u200D", // Zero width joiner
"\u2060", // Word joiner
"\u202C", // Pop directional formatting
"\uFEFF", // Zero width no-break space
"\u00AD", // Soft hyphen
}
var snakeCaseRegex = regexp.MustCompile("^" + snakeCasePattern + "$")