I have a string and I split the string with regexp package. However I could not create a regexp I need.
The regexp code lines:
v = "@636e0e0eac0bd25cd5df92a3$636e0e49ac0bd25cd5df92a5.result.result[0].code.xTrim()"
r, _ := regexp.Compile(`(@[a-zA-Z0-9]+\$[a-zA-Z0-9]+)(.*)`)
variableParts := r.FindStringSubmatch(v)
VariablesParts array:
0: "@636e0e0eac0bd25cd5df92a3$636e0e49ac0bd25cd5df92a5.result.result[0].code.xTrim()"
1: "@636e0e0eac0bd25cd5df92a3$636e0e49ac0bd25cd5df92a5"
2: ".result.result[0].code.xTrim()"
This is my desired result:
Array length can change but array should include this 4 strings.
0: "@636e0e0eac0bd25cd5df92a3$636e0e49ac0bd25cd5df92a5.result.result[0].code.xTrim()"
1: "@636e0e0eac0bd25cd5df92a3$636e0e49ac0bd25cd5df92a5"
2: ".result.result[0].code.xTrim()"
3: ".xTrim()"
How Can I get this result. Which regexp string I need?
UPDATE for new desired result:
1: "@636e0e0eac0bd25cd5df92a3$636e0e49ac0bd25cd5df92a5"
2: ".result.result[0].code.xTrim()"
3: ".result"
4: ".result[0]"
5: ".code"
6: ".xTrim()"
strings.Splitwould be a lot simpler (and faster)\.(.*)at the end.