Golang Regex: FindAllStringSubmatch to []string -


i download multiline file amazon s3 in format like:

columnav1 columnbv1 columncv1 ... columnav2 columnbv2 columncv2 ... 

the file of type byte. want parse regex:

matches := re.findallsubmatch(file,-1) 

then want feed result row row function takes []string input (string[0] columnav1, string[1] columnbv2, ...).

how should convert result of [][][]byte []string containing first, second, etc row? suppose should in loop, cannot working:

for i:=0;i<len(len(matches);i++{     tmp:=myfunction(???) } 

btw, why function findallsubmatch return [][][]byte whereas findallstringsubmatch return [][]string?

(sorry don't have right access real example, syntax may not proper)

it's explained extensively in package's documentation.
read parapgraph explains :

there 16 methods of regexp match regular expression , identify matched text. names matched regular expression:

find(all)?(string)?(submatch)?(index)?

in case, want use findallstringsubmatch.


in go, string read-only []byte.
can choose either keep passing []byte variables around,
or cast []byte values string :

var byteslice = []byte{'f','o','o'} var str string  str = string(byteslice) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -