export const escapeRegExp = ( str ) : string => { return str . replace ( /[.*+?^${}()|[\]\\]/g , '\\$&' ) ; } ; export const removeLeadingZeros = ( str ) : string => { return str . replace ( /^0+(0$|[^0])/ , '$1' ) ; } ; export const count = ( str , search ) : number => { return ( str . match ( new RegExp ( escapeRegExp ( search ) , 'g' ) ) || [ ] ) . length ; } ; export const substringBefore = ( str , search ) : string => { return str . substring ( 0 , str . indexOf ( search ) ) ; } ;