extract-price

1.2.0 • Public • Published

extract-price 🤑

Travis build status Coveralls NPM version Canonical Code Style Twitter Follow

Extracts price from an arbitrary text input.

Usage

import extractPrice from 'extract-price';
 
extractPrice('extracts price from anywhere within the input 1.222.333,50');
// [{amount: 122233350}]
 
extractPrice('understands ,. notation 1,222,333.50');
// [{amount: 122233350}]
 
extractPrice('and ., notation 1.222.333,50');
// [{amount: 122233350}]
 
extractPrice('and space followed by "," notation 1 222 333,50');
// [{amount: 122233350}]
 
extractPrice('and space followed by "." notation 1 222 333.50');
// [{amount: 122233350}]
 
extractPrice('extracts multiple prices listed anywhere within the string using different formats: 1,22, 222, 3,22, 4.20, 5.666');
// [{amount: 12200}, {amount: 22200}, {amount: 322}, {amount: 422}, {amount: 566600}]
 
extractPrice('extracts currency codes EUR 1.00, 2.00 USD');
// [{amount: 100, currencyCode: 'EUR'}, {amount: 200, currencyCode: 'USD'}]
 
extractPrice('extracts currency symbols €1.00, 2.00$');
// [{amount: 100, currencySymbol: '€'}, {amount: 200, currencySymbol: '$'}]
 
extractPrice('does not100 100.20extract ambig0u0s numbers as price');
// []
 

Related projects

  • extract-date – Extracts date from an arbitrary text input.
  • extract-time – Extracts time from an arbitrary text input.

Readme

Keywords

Package Sidebar

Install

npm i extract-price

Weekly Downloads

19

Version

1.2.0

License

BSD-3-Clause

Unpacked Size

32.6 kB

Total Files

36

Last publish

Collaborators

  • gajus