Regexes for changing currency amounts from source to target (German to English)

For a piece I am currently doing, I have a lot of amounts (fines etc. imposed) in the text that use two different Austrian standards for presenting the amount of the fine: They have the following formats.

EUR 600,--
EUR 1 250,--
726,-- EUR
1.400,-- EUR
78,50 EUR

Is there a way using Regex to:

  1. Change the number in the target segment (English) to have the currency code before the amount.
  2. Change the  -- after the decimal comma into 00
  3. Harmonise the thousands separator (non-breaking space or .) 
  4. Add these to the currency formats in Studio 2021.
Parents
  • Interesting query, Michael!

    In addition to the already provided solutions, there is one more I can think of, once again with the help of a Studio app and regular expressions.
    The app in question is the AutoSuggest Provider, where you could use the following search and replace patterns:

    Regex Pattern RegEx Replacement Comment
    EUR[  ]*(\d+),-- EUR $1.00 Replace ",--" by ".00"
    Make sure there is a non-breaking space between "EUR" and amount
    (?<!\d[\.  ])(\d+),--[  ]*EUR EUR $1.00 Replace ",--" by ".00"
    Put "EUR" in front of amount
    Make sure there is a non-breaking space between "EUR" and amount (for amounts smaller than 1000)
    EUR[  ]*(\d{1,3}),(\d{2}) EUR $1.$2 Replace decimal separator "," by "."
    Make sure there is a non-breaking space between "EUR" and amount
    (?<!\d+[\.  ])(\d{1,3}),(\d{2})[  ]*EUR EUR $1.$2 Replace decimal separator "," by "."
    Put "EUR" in front of amount
    Make sure there is a non-breaking space between "EUR" and amount (for amounts smaller than 1000)
    EUR[  ]*(\d{1,3})[\.  ]?(\d{3}),-- EUR $1 $2.00 Replace ",--" by ".00"
    Use non-braking space as thousands separator
    Make sure there is a non-breaking space between "EUR" and amount
    (\d{1,3})[\.  ]?(\d{3}),--[  ]*EUR EUR $1 $2.00 Replace ",--" by ".00"
    Put "EUR" in front of amount
    Use non-braking space as thousands separator
    Make sure there is a non-breaking space between "EUR" and amount
    EUR[  ]*(\d{1,3})[\.  ]?(\d{3}),(\d{2}) EUR $1 $2.$3 Replace decimal separator "," by "."
    Use non-braking space as thousands separator
    Make sure there is a non-breaking space between "EUR" and amount
    (\d{1,3})[\.  ]?(\d{3}),(\d{2})[  ]*EUR EUR $1 $2.$3

    Replace decimal separator "," by "."
    Put "EUR" in front of amount
    Use non-braking space as thousands separator
    Make sure there is a non-breaking space between "EUR" and amount

    Please note that I didn't have the time to verify/test the patterns. I hope this helps nevertheless.

Reply
  • Interesting query, Michael!

    In addition to the already provided solutions, there is one more I can think of, once again with the help of a Studio app and regular expressions.
    The app in question is the AutoSuggest Provider, where you could use the following search and replace patterns:

    Regex Pattern RegEx Replacement Comment
    EUR[  ]*(\d+),-- EUR $1.00 Replace ",--" by ".00"
    Make sure there is a non-breaking space between "EUR" and amount
    (?<!\d[\.  ])(\d+),--[  ]*EUR EUR $1.00 Replace ",--" by ".00"
    Put "EUR" in front of amount
    Make sure there is a non-breaking space between "EUR" and amount (for amounts smaller than 1000)
    EUR[  ]*(\d{1,3}),(\d{2}) EUR $1.$2 Replace decimal separator "," by "."
    Make sure there is a non-breaking space between "EUR" and amount
    (?<!\d+[\.  ])(\d{1,3}),(\d{2})[  ]*EUR EUR $1.$2 Replace decimal separator "," by "."
    Put "EUR" in front of amount
    Make sure there is a non-breaking space between "EUR" and amount (for amounts smaller than 1000)
    EUR[  ]*(\d{1,3})[\.  ]?(\d{3}),-- EUR $1 $2.00 Replace ",--" by ".00"
    Use non-braking space as thousands separator
    Make sure there is a non-breaking space between "EUR" and amount
    (\d{1,3})[\.  ]?(\d{3}),--[  ]*EUR EUR $1 $2.00 Replace ",--" by ".00"
    Put "EUR" in front of amount
    Use non-braking space as thousands separator
    Make sure there is a non-breaking space between "EUR" and amount
    EUR[  ]*(\d{1,3})[\.  ]?(\d{3}),(\d{2}) EUR $1 $2.$3 Replace decimal separator "," by "."
    Use non-braking space as thousands separator
    Make sure there is a non-breaking space between "EUR" and amount
    (\d{1,3})[\.  ]?(\d{3}),(\d{2})[  ]*EUR EUR $1 $2.$3

    Replace decimal separator "," by "."
    Put "EUR" in front of amount
    Use non-braking space as thousands separator
    Make sure there is a non-breaking space between "EUR" and amount

    Please note that I didn't have the time to verify/test the patterns. I hope this helps nevertheless.

Children
No Data