Skip to content

Instantly share code, notes, and snippets.

@tvpsh2020-zz
Last active November 21, 2018 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvpsh2020-zz/d7c69a3ef2af503ca486d5a03def1cdd to your computer and use it in GitHub Desktop.
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
package main
import (
"fmt"
"regexp"
)
func main() {
// GSM 3.38 7-bit string
const GSM0338Regex = `[^A-Za-z0-9 \\r\\n@£$¥èéùìòÇØøÅåΔ_ΦΓΛ¤ΩΠΨΣΘΞÆæßÉ!\"#$%&amp;'()*+,./:;&lt;=&gt;?¡ÄÖÑܧ¿äöñüà^{}\[\~\|\]\<\>\-\\€]*`
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