I'm, trying to split a certain string type to its constituents using Golang's regex.
What I have is a Sprinf(".2f", n)
of any given float (to simplify it to 2 decimal places), and would wish to separate the hundredths digit like:
"1.25" = ["1.2", "5"]
"1.99" = ["1.9", "9"]
In PHP, this is something like:
preg_match('/^ (\-? \d [.] \d) (\d) $/x', sprintf('%1.2f', $input), $matches)
and I can get the parts via $matches[0] and $matches[1].
Tried it with :
re := regexp.MustCompile(`/^ (\-? \d [.] \d) (\d) $/x`)
fmt.Printf("%q
", re.FindAllStringSubmatch("1.50", 2))
to no avail. Thanks in advance.