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

9 Replies, 1496 Views

Hey folks! đź‘‹

So, I’ve been messing around with strings in Go and stumbled upon this thing called *golang string fold contains*. Basically, I need to check if a string contains another string but in a case-insensitive way. Like, "hello" should match "HELLO" or "HeLlO".

I tried using `strings.Contains`, but it’s case-sensitive, so that’s a no-go. Then I heard about `strings.EqualFold`, but that only checks if two strings are equal, not if one’s a substring of the other.

Anyone got tips on how to implement *golang string fold contains* properly? Like, is there a clean way to do this without writing a ton of extra code? Or am I overcomplicating it?

Thanks in advance! 🙏

Messages In This Thread
How to Check for Case-Insensitive Substrings in Go: Best Practices for 'golang string fold contains'? - by - 15-01-2025, 07:25 AM



Users browsing this thread: 1 Guest(s)