Insert a gap after figures



  • Previously written a validation to replace the gaps in the line so that only a certain number of figures could be validated, but it would now be necessary, after the figures, to automatically insert a gap (starting 12b, replacing 12 (b))

    Validation.add('number-validation', '', function(v) {
    var vReplace = v.replace(/\s+/g, '');
    return Validation.get('IsEmpty').test(vReplace) || /^[0-9]{19,19}$/.test(vReplace);});
    


  • var string = '12b 14d',
    result = string.replace(/(\d+)/g, '$1 ');
    
    console.log(result); // > 12 b 14 d
    

    Details: https://learn.javascript.ru/regexp-character-sets-and-ranges




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2