Straker Active Member Licensed User Longtime User Sep 17, 2014 #1 This is my first post, I bought B4A just a couple of days ago and I'm currently learning the language. Probably my question is just sill... be patient. This code doesn't work Code: Copy dim ipAddr as string, l() as string ipAddr = "192.0.0.55" l = regex.split(".", ipAddr) Log(l.length) '<-- returns 0 (which is wrong) Ok, I've found a workaround with: Code: Copy dim ipAddr as string, l() as string ipAdd = "192.0.0.55" l = regex.split(",", ipAddr.Replace(".", ",")) Log(l.length) '<-- returns 4 (CORRECT) The question is: why the first code doesn't work?
This is my first post, I bought B4A just a couple of days ago and I'm currently learning the language. Probably my question is just sill... be patient. This code doesn't work Code: Copy dim ipAddr as string, l() as string ipAddr = "192.0.0.55" l = regex.split(".", ipAddr) Log(l.length) '<-- returns 0 (which is wrong) Ok, I've found a workaround with: Code: Copy dim ipAddr as string, l() as string ipAdd = "192.0.0.55" l = regex.split(",", ipAddr.Replace(".", ",")) Log(l.length) '<-- returns 4 (CORRECT) The question is: why the first code doesn't work?
S sorex Expert Licensed User Longtime User Sep 17, 2014 #2 try with \. or \\. , a dot is a special thing in regex. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Sep 17, 2014 #3 You should escape the dot: \. Upvote 0