@halilhrm0618 said in Parse csv string I'm looking for a different code:
jsimp13:osman8:ericaxx2@freesourcecodxxes.com :sS|1{sWj*4
не могу повторить проблему
Прикрепи проект с проблемой
I want to use JavaScript to solve the problem of finding keywords on a web page. I open a web page and want to check 3 requirements:
I have tried many different ways, but I still encounter an issue with the following case:
Example text to check: "Vietnam"
Keyword to check: "vi"
The methods I tried all resulted in: "true"
However, I want the result to be "false" when the keyword is a part of another word. Please help me.
// Lấy nội dung của trang web và chuyển về chữ thường
var pageContent = document.body.innerHTML.toLowerCase();
// Từ khoá cần kiểm tra và chuyển về chữ thường
var keyword = [[KEY_SEARCH]];
// Tạo biểu thức chính quy để kiểm tra từ khoá trong các liên kết và anchor text
var linkRegex = new RegExp(>[^<]\b${keyword}\b[^<]<a[^>]>|>[^<]\b${keyword}\b[^<]*</a>, 'ig');
// Kiểm tra từ khoá trong các liên kết và anchor text
var keywordInLinks = linkRegex.test(pageContent);
// Loại bỏ các thẻ <a> sau khi đã kiểm tra
var pageContentWithoutLinks = pageContent.replace(linkRegex, ">");
// Kiểm tra từ khoá trong văn bản ngoài các liên kết (với word boundary)
var keywordInText = new RegExp(\b${keyword}\b, 'g').test(pageContentWithoutLinks);
[[XUAT_HIEN_TRONG_LINK]] = keywordInLinks
[[XUAT_HIEN_TRONG_VAN_BAN]] = keywordInText