$arr = array_slice(explode(' ', $str), 1);
.array_map(fn($n) => trim($n, '"'), $arr)
. str.replace(/(\d{2})(\d{2})/, '$1.$2.')
// или
str.replace(/(?=\d{4}$|\d{6}$)/g, '.')
// или
str.match(/(..)(..)(.+)/).slice(1).join('.')
// или
[ 0, 2, 4 ].map((n, i, a) => str.slice(n, a[i + 1])).join`.`
// или
[...str].reduce((acc, n, i) => acc + n + ([ ,'.',,'.' ][i] || ''))
// или
''.concat(...Array.from(str, (n, i) => '24'.includes(i) ? `.${n}` : n))
const utm = Object.fromEntries(Array
.from(new URLSearchParams(location.search))
.filter(n => n[0].startsWith('utm_'))
.map(n => [ n[0].slice(4), n[1] ])
);
str.replace(/\d{3}-\d{2}/, '***-**')
// или
str.slice(0, 9) + '***-**' + str.slice(15)
// или
str.replace(/\d(?=\d*-)/g, '*')
// или
str.replace(/\d+(?=-)/g, m => '*'.repeat(m.length))
// или
str.replace(/(?<=\) ).{6}/, '***-**')
// или
str.match(/^.{9}|.{3}$/g).join('***-**')
document.querySelectorAll('img').forEach(n => {
const src = n.getAttribute('src');
if (!/^https?:\/\//.test(src)) {
const picture = document.createElement('picture');
picture.innerHTML = `<source srcset="${src}" type="image/svg+xml">${n.outerHTML}`;
n.parentElement.replaceChild(picture, n);
}
});
str.match(/(?<=\{{2}).+?(?=\}{2})/g) ?? []
// или
Array.from(str.matchAll(/\{\{(.+?)\}\}/g), n => n[1])
toInsert = 'test.'
newStr = str.dup.sub!(/(?<=www\.)/, toInsert) || (toInsert + str)