Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tokenize (split) string
#6
Here better is findrx. All submatches (enclosed substrings) are exctracted to array starting from indice 1 (0 is for whole match).

Code:
Copy      Help
[color=blue]str [/color]s="1,test;2,site;3,quickmacros"
ARRAY([color=blue]str[/color]) a
[color=blue]str [/color]rx="1,(\w+);2,(\w+);3,(\w+)" [color=green];;if values contain only word characters
;str rx="1,(.+);2,(.+);3,(.+)" ;;if values contain any characters except newline[/color]
[color=blue]if[/color]([color=blue]findrx[/color](s rx 0 0 a)<0) [color=blue]ret[/color]

[color=blue]int [/color]i
[color=blue]for [/color]i 1 a.len
,[color=blue]out [/color]a[i]


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)