import React from 'react';
import styles from './style.module.less';
const highLightString = (keyword, matchString) => {
const highLight = (str) => {
if(!str) {
return '--';
}
const reg = /((\s*)<(\/*)([\sA-Za-z=]*)>(\s*))/g;
const str1 = str.toString().replace(reg, '');
const str2 = str1.replace(/em_full/g, 'span');
const str3 = str2.replace(/em_part/g, 'span');
const str4 = str3.replace(/<span>/g, '<span class=' + styles.matchStr + '>');
return (str4);
};
return (<>
<span
dangerouslySetInnerHTML={
{ _html: highLight(matchString) }
}
>
</span>
</>);
};
.matchStr {
color: #b0020b;
}
export default highLightString;