^(~[A-Za-z]+_(someflag.*?=(.+?)\.~.*|.*)|.*)
echo '~astring_someflag_xds~2.37.0=NEEDED_STRING_TO_EXTRACT.~cha_khe_mil~2.22.0=TADA' \
| perl -pe 's/^(~[a-z]+_(someflag.*?=(.+?)\.~.*|.*)|.*)/\3/i'
$_='~astring_someflag_xds~2.37.0=NEEDED_STRING_TO_EXTRACT.~cha_khe_mil~2.22.0=TADA';
s/^(~[a-z]+_(someflag.*?=(.+?)\.~.*|.*)|.*)/\3/i;
print;
$str = '~astring_someflag_xds~2.37.0=NEEDED_STRING_TO_EXTRACT.~cha_khe_mil~2.22.0=TADA';
preg_match('s/^(~[a-z]+_(someflag.*?=(.+?)\.~.*|.*)|.*)/i', $str, $m);
print($m[3]);
$str = '~astbbhf_sg_fasgs~3.6.0=SOME_OTHER_STRING.~phase2~3.6.0=OLD';
preg_match('/someflag.*=(.+?)\./i', $str, $m);
$result = $m[1];
$result
будет равно null
function lenSort(a, b) {
return a.length - b.length;
}
var intersec = module.exports = function(arrays) {
arrays.sort(lenSort);
var arraysDicts = [];
for (var arrayIndex = 1; arrayIndex < arrays.length; arrayIndex++) {
var dict = {};
for (var index = 0; index < arrays[arrayIndex].length; index++) {
dict[arrays[arrayIndex][index]] = true;
}
arraysDicts.push(dict);
}
var res = [];
for (var index = 0; index < arrays[0].length; index++) {
var flag = true;
for (var arrayIndex = 0; arrayIndex < arraysDicts.length; arrayIndex++) {
if (!(arrays[0][index] in arraysDicts[arrayIndex])) {
flag = false;
break;
}
}
if (flag) res.push(arrays[0][index]);
}
return res;
};