js implementation of intercepting or replacing numbers in strings

  • 2021-06-28 10:27:52
  • OfStack

When js manipulates tables, we often need to get or modify subscripts in name, such as: name="cust[1]/custName";

Replace: name.replace (/[\d]+/, num); //num is the numeric variable you need to replace

Get: name.match (/[\d]+/).

Get multiple: name.match (/[\d]+/g).


Related articles: