MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / cleanString

Function cleanString

strings/palindrome/ispalindrome.go:19–24  ·  view source on GitHub ↗
(text string)

Source from the content-addressed store, hash-verified

17)
18
19func cleanString(text string) string {
20 clean_text := strings.ToLower(text)
21 clean_text = strings.Join(strings.Fields(clean_text), "") // Remove spaces
22 regex, _ := regexp.Compile(`[^\p{L}\p{N} ]+`) // Regular expression for alphanumeric only characters
23 return regex.ReplaceAllString(clean_text, "")
24}
25
26func IsPalindrome(text string) bool {
27 clean_text := cleanString(text)

Callers 2

IsPalindromeFunction · 0.70
IsPalindromeRecursiveFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected