package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)\b(\d{1,}([ ]\d{3})*)([,.] ?(\d*))?\b`)
var str = `== some english sentences ==
pay 123 usd
i want to transfer 100,1234$
how many USD will i get for 47,11 EUR?
Please advice how can I add cash 4000eur on this ban account?
I would like to buy in your bank 3000 euro.
I’ve deposited 2000$ on on the day of opening my account
50€ transferred to my bank account
Why did the bank put the 50,000 US dollars transferred to me into my euro account
== some slovak sentences ==
Ahoj prečo mám na účtu -165 eura ?
Ako uhradim na česky účet 800 CZK ?
Chcem spravit prevod nad limit 30000€
chcem vyplatiť restruktulizovane prečerpanie vo výške 270, 83 €
Adam, potrebujem zamenit 18.000 eur na Ceske koruny. Mozem dostat individualny kurz?
Chcela by som zamenit české koruny v sume 20 000 na eura
Chcem zamenit 10000 forintov na euro mate aj poplatok
chcem si na pobočke v Malackách zameniť 7800 CHF na Euro.
chcel by som zameniť české koruny na euro aký je kurz aake sú poplatky suma by bola 25000ceskych korún
Koľko je 10 000 € keď si zamenim za poľské zlote ?
mám 10.000 USD a chcem ich zameniť na euro
chce aby som zamenil 31eur na doláre
Ak chcem kupovat od banky franky, tak ide zo strany banky o predaj valut, a je tam kurz valuta predaj franky 0,9889
== simple numbers ==
100,10
425,90
50.000kc
62,17 eur
-0,13€
10,- eur
-100€
1000000eur
10134,20cz
4.000
40tisíc
45,000
9.93eur
== length corner cases: ==
12345678901234567890 --> up to 20 digits
1,12345678 --> up to 8 post-comma digits --> value = 1,1235 (rounded)?
1,12345678 --> up to 8 post-comma digits --> value = 1,1234 (truncated)?
123.123.123,123567 --> what about more than 4 decimal places:
--> to be confirmed
== unusual post-comma leghts: ==
10,1
10,123
== what about separators for thousand groups like: ==
123.123.123,00 EUR
123 123 123 USD
--> this is questionable (not usual in Slovak)
== allow dot for comma? ==
123.12 --> value = 123,1200
--> yes, as answered in Inez's questions: ‘,‘ and ‘.‘ are expected only as decimal separators in decimal numbers not as separators of hundreds/thousands etc. (not typical in written Slovak)
== things that would NOT need disambiguation: ==
123.456 --> to map to value 123,4560 and NOT 123456,0000 !
--> dot considered as decimal separator so map to 123,4560
== things that would need disambiguation: ==
- none -
`
var substitution = "[$0 --> ($1),($4)]"
fmt.Println(re.ReplaceAllString(str, substitution))
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/