Encountering an unusual issue while attempting to compare two strings using regex. Even after comparing both variables in the watch, the result remains the same. Seeking assistance in identifying the cause.
Below is my code and also an image showcasing the comparison of two variable values.
In the code snippet below, if text="Acworth, GA"
and search="Acworth, GA"
or search="acworth, ga"
, then final_str
does not contain <span class="highlight"
.
Open to any suggestions or guidance that can be provided.
app.filter('highlight', function($filter, $sce) {
return function(text, search, caseSensitive) {
if (search == undefined)
search = searchDataBrowser;
text = text.toString();
search = search.toString();
var reg = new RegExp(search, 'gi');
var final_str = text.replace(reg, function(str) {
return '<span class="highlight">' + str + '</span>'
});
return $sce.trustAsHtml(final_str);
};
});