NewFromFormattedString returns a new Decimal from a formatted string representation. The second argument - replRegexp, is a regular expression that is used to find characters that should be removed from given decimal string representation. All matched characters will be replaced with an empty string
(value string, replRegexp *regexp.Regexp)
| 263 | // r3 := regexp.MustCompile("[USD\\s]") |
| 264 | // d3, err := NewFromFormattedString("5000 USD", r3) |
| 265 | func NewFromFormattedString(value string, replRegexp *regexp.Regexp) (Decimal, error) { |
| 266 | parsedValue := replRegexp.ReplaceAllString(value, "") |
| 267 | d, err := NewFromString(parsedValue) |
| 268 | if err != nil { |
| 269 | return Decimal{}, err |
| 270 | } |
| 271 | return d, nil |
| 272 | } |
| 273 | |
| 274 | // RequireFromString returns a new Decimal from a string representation |
| 275 | // or panics if NewFromString had returned an error. |
searching dependent graphs…