Documentation
¶
Index ¶
- Variables
- func CountByteLeft(s string, b byte) int
- func CountByteRight(s string, b byte) int
- func CutLeftByte(s string, c byte) (before, after string, found bool)
- func CutLeftRune(s string, r rune) (before, after string, found bool)
- func CutRightByte(s string, c byte) (before, after string, found bool)
- func CutRightRune(s string, r rune) (before, after string, found bool)
- func Match(pattern, str string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBadPattern indicates a pattern was malformed. ErrBadPattern = errors.New("zstrings: syntax error in pattern") )
Functions ¶
func CountByteLeft ¶
CountByteLeft counts the number of b from the lest side of s until non b found. For example, CountByteLeft("aabc",'a') returns 2.
func CountByteRight ¶
CountByteRight counts the number of b from the right side of s until non b found. For example, CountByteRight("abcc",'c') returns 2.
func CutLeftByte ¶
CutLeftByte slices the given string s at the first instance of c, returning the text before and after the separator of c. The found result reports whether c appears in s. The separator c is not contained both before and after. If the separator c does not appear in s, cut returns s, "", false. See also strings.Cut and strings.IndexByte.
func CutLeftRune ¶
CutLeftRune slices the given string s at the first instance of r, returning the text before and after the separator of r. The found result reports whether r appears in s. The separator r is not contained both before and after. If the separator r does not appear in s, cut returns s, "", false. If the given r is not valid UTF-8 rune, it also returns s, "", false. CutLeftRune uses Brute Force strategy for all s. See also strings.IndexRune.
func CutRightByte ¶
CutRightByte slices the given string s at the last instance of c, returning the text before and after the separator of c. The found result reports whether c appears in s. The separator c is not contained both before and after. If the separator c does not appear in s, cut returns s, "", false. See also strings.Cut and strings.LastIndexByte.
func CutRightRune ¶
CutRightRune slices the given string s at the last instance of r, returning the text before and after the separator of r. The found result reports whether r appears in s. The separator r is not contained both before and after. If the separator r does not appear in s, cut returns s, "", false. If the given r is not valid UTF-8 rune, it also returns s, "", false. CutLeftRune uses Brute Force strategy for all s. See also strings.IndexRune.
func Match ¶
Match reports whether the str matches the pattern. Match is simpler and faster match function similar to path.Match or path/filepath.Match. The only error returned is ErrBadPattern when the given pattern has single "\\" at the end of its pattern.
The pattern syntax is:
pattern: { term } term: '*' matches any sequence of characters '?' matches any single character c matches character c (c != '*', '?') '\\' c matches character c
Types ¶
This section is empty.