javascript - Is it possible to strip more than X digits in a string using regex? -


I am trying to filter points by string, when the string gets 6 or more digits.

I do not want to remove the digits all in the string, only anyone 6 and more The first 5 should be kept.

For example:

  var val = 'Hello, this is my lesson I was born in 1984, and currently my age is 29 Year is; If (any matches in the match (/ [0- 9] / g, ''), length> 5) {// any number bar above 5th}}  

whatever It also comes in if, now in Val:

  var val = 'Hello, this is my lesson I was born in 1984, and at present my age is 2 years;  

I think that maybe something very easy for this is that I am ignoring, though my search on the web was not generated.

  var val = 'Hello, this is my lesson I was born in 1984 , And currently my age is 29 years; Var calculation = 0; Var str = val.replace (/ \ d / g, function (match) {return (++ calculation & lt; 6) match: "";}); Console.log (STR);  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -