// getratecurrency
package clear

import (
	"fmt"
	"regexp"
)

var currency *regexp.Regexp
var encyitem = map[string]string{
	"$": "美元", "＄": "美元", "美元": "美元",
	//待续
}

func init() {
	//提取币种
	currency, _ = regexp.Compile(`[$|＄|美元]+`)
}

//获取币种
func GetCurrency(data []interface{}) []interface{} {
	val := "人民币"
	currency.ReplaceAllStringFunc(fmt.Sprint(data[0]), func(key string) string {
		v := encyitem[key]
		if v != "" {
			val = v
		}
		return key
	})
	data[0] = val
	return data
}
