var filter = new RegExp('\n' + selectedText + '\n', 'i');
if(allText.match(filter)) {}
function processSelection() {
var text = document.getElementById('myTextareaId');
var sel = new RegExp('\\n*(' + text.value.substring(text.selectionStart, text.selectionEnd) + ')', 'i');
text.value = text.value.replace(sel, '\n$1'));
}