I have a following html string in which a date range has to be replaced.
var htmlStr = "<strong>1-Mar-2015</strong>"+
"<span> to </span>"+
"<strong>15-Feb-2016</strong><br>"+
"<span>by </span>"+
"<strong>Week</strong><br>"+
"<span>Key</span>"+
"<span> is </span>"+
"<strong>Key Value</strong><br>"+
"<span>Type</span>"+
"<span> is </span>"+
"<strong>Report</strong>"+
"<span> or </span>"+
"<strong>Incident</strong><br>"+
"<span>SomeKey</span>"+
"<span> is </span>"+
"<strong>SomeValue</strong>";
I want to replace the date range with some specific date range. For now i am breaking the html string with br tag to divide different properties and trying to replace the content of first and second strong tag.
I am looking for possible Regex solution to replace date range.
The js code flow is as follows:
var startdate = '2-Jun-2012';//selected from dom
var enddate = '24-Sept-2014';//selected from dom
for(var i = 0; i < IDList.length; i++ ) {
var htmstr = loadHtmlDataFromServer(IDList[i]); //will get html type content from server
//if startdate and enddate value exist, update htmstr
CreateModal(htmlstr, IDList[i]);
}
strongtags?$("strong:eq(0)").text(startDate)and$("strong:eq(1)").text(endDate)