Convert amount in the right format with different input format

The Idea:
Use regex to detect the format
With the help of Regex Groupname we calculate the CultureInfo

grafik

we do see 10 000.00 as uncatched (currently no matching Culture Info is known)

Extreme Check
grafik

But (we can cross safe if needed) when removing space we can simplify
grafik

Prototypes:
Add namespaces:
grafik

Get Matching Group Name (unoptimized ProtoType)


if no or more Group names were found the Single() method throws an exception

use the calculated info and parse it with the corresponding CultureInfo
grafik

Variables:

Flow with Testseries:
grafik

myMatch = myRegex.Match(item.replace(" ",""))
myGroupName = myRegex.GetGroupNames.Skip(1).Where(Function (x) myMatch.Groups(x).Success).Single
myDouble = Double.Parse(item.Replace(" ",""), dictCultureLK(myGroupName))

Logs:
grafik

This is one of many options focussing on extensibility and control

Find starter help here:
DoubleParsing_MultiNationalFormats.xaml (9.2 KB)

4 Likes