Last active
November 21, 2018 03:37
-
-
Save tvpsh2020-zz/d7c69a3ef2af503ca486d5a03def1cdd to your computer and use it in GitHub Desktop.
Golang GSM 03.38 7-bit alphabet regular expressions example. See definition: https://en.wikipedia.org/wiki/GSM_03.38
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" | |
"regexp" | |
) | |
func main() { | |
// GSM 3.38 7-bit string | |
const GSM0338Regex = `[^A-Za-z0-9 \\r\\n@£$¥èéùìòÇØøÅåΔ_ΦΓΛ¤ΩΠΨΣΘΞÆæßÉ!\"#$%&'()*+,./:;<=>?¡ÄÖÑܧ¿äöñüà^{}\[\~\|\]\<\>\-\\€]*` | |
testString := "你好HelloWorldこんにちは" | |
regexpHelper := regexp.MustCompile(GSM0338Regex) | |
for index, match := range regexpHelper.FindAllString(testString, -1) { | |
if len(match) > 0 { | |
fmt.Println(index, ":", match) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment