-
-
Save RavenZZ/751e60336c12a396e9c77e5759bdcd1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"regexp" | |
) | |
func main() { | |
example := "#GoLa啊啊|ngCode!$!" | |
result := removeNonEng(example) | |
fmt.Printf("A string of %s becomes %s \n", example, result) | |
} | |
func removeNonEng(input string) string { | |
reg, err := regexp.Compile("[^a-zA-Z0-9]+") | |
if err != nil { | |
log.Fatal(err) | |
} | |
processedString := reg.ReplaceAllString(input, "") | |
return processedString | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment