I want to be able to split the string into substrings where characters and numbers are separate groups:
re:=regexp.MustCompile("**MAGIC HERE**")
fmt.Println(re.FindAllString("abc123def", -1))
I want to be able to get
[abc 123 def]
Any ideas?
I want to be able to split the string into substrings where characters and numbers are separate groups:
re:=regexp.MustCompile("**MAGIC HERE**")
fmt.Println(re.FindAllString("abc123def", -1))
I want to be able to get
[abc 123 def]
Any ideas?
Try splitting on this pattern:
\d+|\D+
Code:
re:=regexp.MustCompile("\\d+|\\D+")
fmt.Println(re.FindAllString("abc123def", -1))
Output:
[abc 123 def]
Demo here: