---
title: Decimal.ParseStrategy
framework: foundation
role: symbol
role_heading: Structure
path: foundation/decimal/parsestrategy
---

# Decimal.ParseStrategy

A parse strategy for creating decimal values from formatted strings.

## Declaration

```swift
struct ParseStrategy<Format> where Format : FormatStyle, Format.FormatInput == Decimal
```

## Overview

Overview Create an explicit Decimal.ParseStrategy to parse mulitple strings according to the same parse strategy. In the following example, usCurrencyStrategy is a Decimal.ParseStrategy that uses US dollars and the en_US locale’s conventions for number formatting. The example then uses this strategy to parse an array of strings, some of which represent valid US currency values. let usCurrencyStrategy: Decimal.ParseStrategy = Decimal.FormatStyle.Currency(code: "USD",                              locale: Locale(identifier: "en_US")) .parseStrategy let currencyValues = ["$100.11", "$1,000.22", "$10,000.33", "€100.44"] let parsedValues = currencyValues.map { try? usCurrencyStrategy.parse($0) } // [Optional(100.11), Optional(1000.22), Optional(10000.33), nil] You don’t need to instantiate a parse strategy variable to parse a single string. Instead, use the init(_:format:lenient:) initializer, which takes a source String and a format parameter to parse the string according to the provided Decimal.FormatStyle. The following example parses a string that represents a currency value in US dollars. let formattedUSDollars = "$1,234.56" let parsedUSDollars = try? Decimal(formattedUSDollars, format: .currency(code: "USD")     .locale(Locale(identifier: "en_US"))) // 1234.56 Decimal also has an init(_:strategy:) initializer, if it’s more convenient to pass a Decimal.ParseStrategy instance rather than implicitly derive a strategy from a Decimal.FormatStyle.

## Topics

### Creating a decimal parse strategy

- [init(format:lenient:)](foundation/decimal/parsestrategy/init(format:lenient:)-46ix2.md)
- [init(format:lenient:)](foundation/decimal/parsestrategy/init(format:lenient:)-22h06.md)
- [init(format:lenient:)](foundation/decimal/parsestrategy/init(format:lenient:)-36ja3.md)

### Parsing strings

- [parse(_:)](foundation/decimal/parsestrategy/parse(_:).md)

### Accessing strategy properties

- [formatStyle](foundation/decimal/parsestrategy/formatstyle.md)
- [lenient](foundation/decimal/parsestrategy/lenient.md)

### Default Implementations

- [ParseStrategy Implementations](foundation/decimal/parsestrategy/parsestrategy-implementations.md)

## Relationships

### Conforms To

- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [ParseStrategy](foundation/parsestrategy.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Data parsing in Swift

- [ParseableFormatStyle](foundation/parseableformatstyle.md)
- [ParseStrategy](foundation/parsestrategy.md)
- [IntegerParseStrategy](foundation/integerparsestrategy.md)
- [FloatingPointParseStrategy](foundation/floatingpointparsestrategy.md)
