Ranon Kahn Ranon Kahn - 3 months ago 24
Javascript Question

How to highlight a substring containing a random character between two known characters using javascript?

How to highlight the substring 'NxG' where 'x' could be any character between 'N' and 'G' in a string like "ARSTNFGATTATNMGATGHTGNKGTEEFR" with a new FG and BG color?

datatable(DF, options = list(rowCallback=JS("function(row,data) {
data[0] = data[0] .replace(/NxG/g,'<span style=\"color:blue; font-weight:bold\"\">NxG</span>');
$('td:eq(0)', row).html(data[0] );}" ), dom = 't'))


I think the regex you want is: /N[A-Z]G/g

If you also want it to work for lower case: /N[A-Za-z]G/g