Pattern: Currency

“Currency” is one of the patterns that you can select on the Match panel. Use this pattern to make a field match a currency code as defined in the ISO 4217 standard. You can restrict the field to specific currencies.

Suppose you have a database of orders for a company that accepts various currencies. The database stores a three-letter ISO currency code for each order. You want to retrieve all orders in euro (and British pounds. from customers based in the European Union. You want to create a regular expression that matches these two currency codes. You can find this example as “Pattern: currency” in the RegexMagic library.

  1. Click the New Formula button on the top toolbar to clear out all settings on the Samples, Match, and Action panels.
  2. On the Samples panel, paste in one new sample:
    USD
    CAD
    EUR
    GBP
  3. On the Match panel, select EUR in the sample text and click the Mark button. RegexMagic automatically adds a field using the currency pattern with “EUR Euro” selected in the list of currencies.
  4. Select GBP in the sample text and click button 1. RegexMagic automatically selects “GBP Pound sterling” in the list of currencies.



  5. On the Regex panel, select “C# (.NET 2.0–4.8 & .NET Core 1.0–3.0)” as your application, turn off free-spacing, and turn off mode modifiers. Click the Generate button, and you’ll get this regular expression:
    EUR|GBP

    Required options: Case insensitive.
    Unused options: Exact spacing; Dot doesn’t match line breaks; ^$ don’t match at line breaks; Numbered capture.

  6. On the Use panel, select a database such as MySQL, Oracle, or PostgreSQL in the Language drop-down list.
  7. In the Function drop-down list, choose “select rows in which a column is entirely matched by the regex”.
  8. Enter the name of table you’re selecting rows from and the name of the column with the currency code to generate a SQL statement for selecting all orders in euro and pounds.

Reference