Repository navigation
v1.3.0
This release expands str with a small set of high-leverage additions:
- Case-insensitive search helpers now include positional and counting APIs.
- New character-class predicates cover common validation checks.
- Word and affix helpers fill a few practical gaps without expanding the surface area.
- Native-type conversions were added in a deliberately minimal form:
Int,Float64, andBool.
str aims to be intentionally simple by providing sane defaults, no aliased helpers and high-value primitives.
Search
IndexFold()
Returns the rune index of the first case-insensitive match.
v := str.Of("Go gopher GO").IndexFold("go")
println(v)
// 0LastIndexFold()
Returns the rune index of the last case-insensitive match.
v := str.Of("Go gopher GO").LastIndexFold("go")
println(v)
// 10CountFold()
Counts non-overlapping case-insensitive matches.
v := str.Of("GoGOgophergo").CountFold("go")
println(v)
// 4Checks
IsAlpha()
Reports whether a string consists only of Unicode letters.
v := str.Of("Gopher").IsAlpha()
println(v)
// trueIsAlnum()
Reports whether a string consists only of Unicode letters or numbers.
v := str.Of("Gopher2025").IsAlnum()
println(v)
// trueIsNumeric()
Reports whether a string consists only of Unicode numbers.
v := str.Of("12345").IsNumeric()
println(v)
// trueWords
Initials()
Extracts the uppercase first rune of each detected word.
v := str.Of("portableNetwork graphics").Initials().String()
println(v)
// PNGSubstrings
BeforeFold()
Returns the substring before the first case-insensitive separator match.
v := str.Of("GoPHER::go").BeforeFold("::GO").String()
println(v)
// GoPHERAfterFold()
Returns the substring after the first case-insensitive separator match.
v := str.Of("gopher::GO-team").AfterFold("::go").String()
println(v)
// -teamBeforeLastFold()
Returns the substring before the last case-insensitive separator match.
v := str.Of("pkg/Path/FILE.txt").BeforeLastFold("/path/").String()
println(v)
// pkgAfterLastFold()
Returns the substring after the last case-insensitive separator match.
v := str.Of("pkg/Path/FILE.txt").AfterLastFold("/path/").String()
println(v)
// FILE.txtCommonPrefix()
Returns the longest shared prefix across the receiver and the provided strings.
v := str.Of("gopher").CommonPrefix("go", "gold").String()
println(v)
// goCommonSuffix()
Returns the longest shared suffix across the receiver and the provided strings.
v := str.Of("main_test.go").CommonSuffix("user_test.go", "api_test.go").String()
println(v)
// _test.goAffixes
HasSurrounding()
Reports whether a string starts and ends with the expected delimiters.
v := str.Of(`"GoForj"`).HasSurrounding(`"`, "")
println(v)
// trueConversion
Int()
Parses the string as a base-10 int using strict strconv.Atoi semantics.
v, err := str.Of("42").Int()
println(v, err == nil)
// 42 trueFloat64()
Parses the string as a float64 using strict strconv.ParseFloat semantics.
v, err := str.Of("3.14").Float64()
println(v, err == nil)
// 3.14 trueBool()
Parses the string as a bool using strict strconv.ParseBool semantics.
v, err := str.Of("true").Bool()
println(v, err == nil)
// true trueFull Changelog: v1.2.0...v1.3.0