jeudi 3 août 2017

Regex Split Exchange Rates

I have a string like this :

{"base":"CHF","date":"2017-08-03","rates":{"AUD":1.2993,"BGN":1.7005,"BRL":3.2186,"CAD":1.3,"CNY":6.9321,"CZK":22.576,"DKK":6.4674,"GBP":0.78531,"HKD":8.0623,"HRK":6.4397,"HUF":264.1,"IDR":13741.0,"ILS":3.6954,"INR":65.665,"JPY":113.82,"KRW":1162.1,"MXN":18.384,"MYR":4.4153,"NOK":8.153,"NZD":1.39,"PHP":51.843,"PLN":3.6976,"RON":3.9697,"RUB":62.324,"SEK":8.3552,"SGD":1.4025,"THB":34.283,"TRY":3.6512,"USD":1.0312,"ZAR":13.706,"EUR":0.86949}}

(Source : http://ift.tt/2wbAfSJ)

What Regex Pattern can I use to extract the given exchange rate by specifying the currency?

For example :

For "PLN" it should return 3.6976
For "USD" it should return 1.0312

Whats the best pattern to use here?

Aucun commentaire:

Enregistrer un commentaire