๐ฐreplacer function
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
JS โฉ value โฉ primitive โฉ String โฉ method โฉ .replace() โฉ replacer function
๐็ฏไพ๏ผ
minus one - replacer function example.
codepen โฉ str.replace()
// p1: nondigits
// p2: digits
// p3: non-alphanumerics
let regex = /([^\d]+)(\d+)([^\w]+)/;
// groups: โฐโ p1 โโฏโฐp2โโฏโฐโ p3 โโฏ
// offset โด
// 012345678901234567
let str
๐็ฏไพ๏ผ
// replace function
"the cia and fbi".replace(/\b(fbi|cia)\b/g,
match => match.toUpperCase() // โ the CIA and FBI
)