function $(id) { return document.getElementById(id); } function cut_or_add(obj) { val = $('get_div').value; replace = val.replace(new RegExp(obj, 'g'), ''); $('get_div').value = replace; // сие вырезает значение obj из val } How to determine that the value of obj is missing in val and add it there? I only need to determine its absence. Tell me what the condition will look like based on a regular expression?