JSFiddle - React, Tailwind, and code Playground
HTML
<div id ="div" data-year="2015">
what bozo where 2015
</div>
JavaScript
/*
var value = 'bozo';
var str = $("#div").html();
var regexExpression ="(?!(?:[^<]+>|[^>]+<\\/a>))\\b(" + value + ")\\b";
var regex = new RegExp(regexExpression, "i");
$("#div").html(str.replace(regex, "<a href='#" + value +"'>" + value + "</a>"));
*/
var value = '20'; //token
var html = $("#div").html(); //data.()
var dataAtt = $('#div').data('year').toString();
var regex = new RegExp("\\b\\w*" + value + "\\w*\\b");
if( dataAtt.match(regex) ){
console.log(dataAtt + " matched");
} else {
console.log('nope')
}