serhiiko-regexp-parser
v2.0.1
Published
``` npm i serhiiko-regexp-parser``` ## Usage Import npm module ```const regexp = require('serhiiko-regexp-parser');``` ## Functions 1. regexp.toNumber(str) ``` /** * Find number in the string and returns it * * @param {string} str Text in which shoul
Downloads
6
Readme
Service helper which parse different patterns of string
Installation
npm i serhiiko-regexp-parser
Usage
Import npm moduleconst regexp = require('serhiiko-regexp-parser');
Functions
- regexp.toNumber(str)
/**
* Find number in the string and returns it
*
* @param {string} str Text in which should be founded number
* @returns {number|undefined}
*/
- regexp.getTextBetween(allText, firstText, secondText, thirdText)
/**
* Find middle part of the string between 1 & 2 breakpoints
* in case if second breakpoint don't exist find between 1 & 3
*
* @param {string} allText String in whish searched middle part
* @param {string} firstText First text breakpoint
* @param {string} secondText Second breakpoint
* @param {string} thirdText Third breakpoint
* @returns {string|undefined}
*/
- regexp.getNumberAfterStr(allText, word)
/**
* Find number after text breakpoint
*
* @param {string} allText Text in which should be founded number
* @param {string} word Text breakpoint
* @returns {number|undefined}
*/
- regexp.stringPriceToNumber(str)
/**
* Convert price from formats:
* <number Тыс $>
* <number Млн $>
* <number Млрд $>
* to normal number
*
* @param {string} str String with price
* @returns {number|undefined}
*/
- regexp.stringDateToTime(strDate)
/**
* Convert date string from formats
* DD.MM.YYYY
* DD-MM-YYYY
* DD month YYYY (russian)
* to Date.getTime() format
*
* @param {string} strDate
* @returns {number|undefined}
*/
- regexp.numStrToArray(str)
/**
* Find all pairs of (string and numbers) and (number and strings)
* depends on what is first
* Example:
* Sehic6.64.Kvrzic6.43. => [
* {
* str: 'Sehic',
* num: '6.64'
* },
* {
* str: 'Kvrzic',
* num: '6.43'
* },
* ]
*
* @param {string} str
* @returns {Array<TextNum>|undefined}
*/
/**
* @typedef {Object} TextNum
* @property {string} text
* @property {number} num
*/