JSFiddle - React, Tailwind, and code Playground

by Kirubel Girma

JavaScript

var data = `The purpose of a child protective investigation is to assess whether the child[^1] named in a State Central Register of Child Abuse and Maltreatment (SCR) report is abused or maltreated, and to assess safety and risk. When the ACS Division of Child Protection (DCP) receives an SCR report, an investigation or assessment must begin within 24 hours.[^2] While an SCR[^3] report may include multiple safety concerns and involve diverse family dynamics, the Child[^4] Protective Specialist (CPS) must complete all minimum components of an investigation or[^5] CARES/FAR assessment referenced[^6] in this[^7] chapter[^8].`

footerReplace_firstIndx(98);

function footerReplace_firstIndx(startFrom, filedata) {
  var matched = data.match(/\[\^(\d*)]/gm)
  for (var i = 0; i < matched.length; i++) {
    console.log(matched[i], matched[i].replace(/(\[\^)\d*(])/gm, "[^" + startFrom++ + "]"))
  }
  console.log()
}