How to Check for Case-Insensitive Substrings in Go: Best Practices for 'golang string fold contains'?

9 Replies, 1534 Views

Dude, just use regex! It’s overkill but super flexible.

```go
import "regexp"

func foldContains(main, sub string) bool {
re := regexp.MustCompile(`(?i)` + regexp.QuoteMeta(sub))
return re.MatchString(main)
}
```
The `(?i)` flag makes it case-insensitive. Works like a charm for golang string fold contains.

Messages In This Thread



Users browsing this thread: 1 Guest(s)