I am trying to remove everything between two words with brackets. The words are: {start}
and {end}
(function ($) {
$(document).ready(function(){
$('.well.save').on('mouseleave touchend', function(){
// alert('mouseleave touchend');
var $editor = $(".markItUpEditor");
var curValue = $editor.val();
//alert(curValue);
// check
var confCheck = curValue.includes("{start}");
//alert(confCheck);
if (confCheck == true) {
var myStr = $editor.val();
var subStr = myStr.match("{start}(.*){end}");
alert(subStr[1]);
//$editor.val(curValue);
}
});
})(jQuery);
The code above returns null.
I am getting the content from a textarea. This textarea has a section with text added on mouseleave. This section starts with the word {start}
and ends with the word {end}
now I want to remove everything between those two words and the words as well so that on the next mouse leave I can re-add updated information.
Jquery version is from native Joomla 3. And the textarea contains the following:
There is some text in the message!
[confidential]
{start}
Site URL:
Site Username:
Site Password:
FTP URL:
FTP Username:
FTP Password:
Optional Information:
{end}
[/confidential]```