Skip to content

Instantly share code, notes, and snippets.

@bayucandra
Created June 23, 2020 08:28
Show Gist options
  • Save bayucandra/3d8e3862dc6b54a56afe4d132552cea2 to your computer and use it in GitHub Desktop.
Save bayucandra/3d8e3862dc6b54a56afe4d132552cea2 to your computer and use it in GitHub Desktop.
package main
//https://play.golang.org/p/_iu24fTdt57
import (
"fmt"
"regexp"
)
func main() {
str := `an..19` //https://en.wikipedia.org/wiki/ISO_8583#Examples_3
r := regexp.MustCompile(`^([a-z]+)(\.+)?([0-9]+)$`)
res := r.FindStringSubmatch(str)
dataType := res[1]
dataLengthNotation := res[2]
dataLength := res[3]
fmt.Println(" - dataType:", dataType, "\n - length notation:", dataLengthNotation, "\n - dataLength:", dataLength)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment