u
:preg_match_all("/[а-я]{4,}/ui", $string, $keywords);
$result = implode(',', array_column(json_decode($str), 'v'));
preg_match_all('~(?<="v": )\d+~', $str, $match);
$result = implode(',', $match[0]);
preg_match('~\d{2}\.\d{1,2}~', preg_replace('~[^\d.]~', '', $str), $match);
function getStrings(str) {
const str1 = str.match(/\(.+?\)/g)?.find(n => /\d/.test(n)) ?? '';
return {
str1: str1.slice(1, -1),
str2: str.replace(str1, ''),
};
}
str.split('"').filter((n, i) => i & 1)
// или
str.match(/".*?"/g)?.map(n => n.slice(1, -1)) ?? []
// или
Array.from(str.matchAll(/"([^"]*)"/g), n => n[1])
// или
Array.prototype.reduce.call(str, (acc, n) => {
if (n !== '"') {
acc[1]?.push(n);
} else if (acc[1]) {
acc[0].push(acc[1].join(''));
acc[1] = null;
} else {
acc[1] = [];
}
return acc;
}, [ [], null ])[0]