Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
CopyDigits function ref
package main
// ref:
// 1234 <-- digits
import (
var digitRegexp = regexp.MustCompile("[0-9]+")
func CopyDigits(filename string) []byte {
b, _ := ioutil.ReadFile(filename)
b = digitRegexp.Find(b)
return append([]byte{}, b...)
func main() {
digits := CopyDigits("./copy-digits.go")

takatoshiono commented Aug 25, 2016

$ go run copy-digits.go
[49 50 51 52]

takatoshiono commented Aug 25, 2016 more concise version of this function could be constructed by using append. This is left as an exercise for the reader. というのをやってみた

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment