js regex variable & Set, Map

regex, variable, Set, Map, 交集, 差集, 并集,

https://stackoverflow.com/questions/494035/how-do-you-use-a-variable-in-a-regular-expression

https://www.hacksparrow.com/javascript-use-variables-with-regular-expressions.html

Regex is not Work for Inner keyword!


let newsTitle = `长安汽车无惧与外资公平竞争`; let newTitle = `长安无惧与外资公平竞争`; let newsHighLightTitleBackup = `长安汽车无惧与外资公平竞争`; let newsHighLightTitle = `长安<span class="audit-label-highlight-color">汽车</span>无惧与外资公平竞争`; newsHighLightTitleBackup.replace(newTitle, ``);
// "长安汽车无惧与外资公平竞争" let reg = new RegExp(newTitle);
newsHighLightTitleBackup.replace(reg, ``);
// "长安汽车无惧与外资公平竞争"

js & get two string diff

ES6 & ES next

Map & Set

https://stackoverflow.com/questions/1187518/how-to-get-the-difference-between-two-arrays-in-javascript/33034768#33034768

https://stackoverflow.com/questions/1187518/how-to-get-the-difference-between-two-arrays-in-javascript/52430020#52430020

//  交集
let intersection = arr1.filter(x => arr2.includes(x)); // 差集
let difference = arr1.filter(x => !arr2.includes(x)); let difference = arr1
.filter(x => !arr2.includes(x))
.concat(arr2.filter(x => !arr1.includes(x))); // 补集 // 并集

https://stackoverflow.com/questions/8024102/javascript-compare-strings-and-get-end-difference

https://stackoverflow.com/questions/2167602/optimum-way-to-compare-strings-in-javascript

https://stackoverflow.com/questions/1187518/how-to-get-the-difference-between-two-arrays-in-javascript

https://stackoverflow.com/questions/18050932/detect-differences-between-two-strings-with-javascript


css highlight keywords

let key = `zzz`.toLocaleUpperCase();
let name = `XXXzzzYYYZZZaaazzzCCC`; let regx = new RegExp(key, "ig");
name.replace(regx, `<span class="highlight-color">${key}</span>`);

js regex variable & Set, Map的更多相关文章

  1. JS数组filter()、map()、some()、every()、forEach()、lastIndexOf()、indexOf()实例

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat=&qu ...

  2. java和js中JSONObject,JSONArray,Map,String之间转换

    --------------------------------------------------Java中--------------------------------------------- ...

  3. react / config\webpack.config.js 编译后去掉map 减小体积 shouldUseSourceMap = false

    react / config\webpack.config.js 编译后去掉map 减小体积 shouldUseSourceMap = false

  4. js & regex & var & highlight

    js & regex & var & highlight let key = `ali`.toLocaleUpperCase(); let name = "阿里云计算 ...

  5. js解析json,js转换json成map,获取map的key,value

    json串格式 { "10.10.11.1": { "target_1": "34.2", "target_3": &q ...

  6. js原生forEach、map与jquery的each、$.each的区别

    <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...

  7. js ES6 Set和Map数据结构详解

    这篇文章主要介绍了ES6学习笔记之Set和Map数据结构,结合实例形式详细分析了ECMAScript中基本数据结构Set和Map的常用属性与方法的功能.用法及相关注意事项,需要的朋友可以参考下   本 ...

  8. [Functional Programming 101] Crocks.js -- when to use map and when to use chain?

    As a beginner of Crocks.js, it was a problem for we to figure out when to use .map() and when to use ...

  9. JS中forEach和map的区别

    共同点: 1.都是循环遍历数组中的每一项. 2.forEach()和map()里面每一次执行匿名函数都支持3个参数:数组中的当前项item,当前项的索引index,原始数组input. 3.匿名函数中 ...

随机推荐

  1. Google的Flutter工具允许开发者开发跨平台应用

    与大多数应用程序开发人员交谈,他们会告诉你,与iOS相比,制作Android应用程序要困难得多,也更复杂,也不那么有趣.实际上,如果你要求报价,这两种软件都将单独定价,因为它们都需要单独的开发时间和团 ...

  2. 深入浅出的webpack4构建工具---Scope Hoisting(十六)

    一:什么是Scope Hoisting? 它有什么作用?Scope Hoisting 它可以让webpack打包出来的代码文件更小,运行更快,它可以被称作为 "作用域提升".是在w ...

  3. 阿里图标库使用IconFont

    1.注册账号登陆 2.创建项目 3.搜索想使用的图标,添加入库,或者上传自己的图标入库 4.在图标库中,将添加的图标加入项目 5.将项目图标下载至本地 6.下载文件为 包括三种格式,使用方法不同 Un ...

  4. MySQL 基础八 用户管理

    SELECT * FROM student INSERT INTO student(NAME,sex,createuser,createtime) VALUES('jack','男','ligenyu ...

  5. Linux下DHCP服务安装配置

    简介 安装配置 一.简介 DHCP (Dynamic Host Configuration Protocol,动态主机管理协议)是一种基于UDP协议且仅限用于局域网的网络协议,主要用途是为局域网内部设 ...

  6. Omi框架学习之旅 - 插件机制之omi-router及原理说明

    先来看看官网的介绍吧:https://github.com/AlloyTeam/omi/tree/master/plugins/omi-router 其实我推荐直接看官网的介绍.我所写的,主要给个人做 ...

  7. SkylineGlobe 6.6 三维地图上实现自定义右键菜单示例代码

    1.OnRButtonDown.htm <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo ...

  8. 《MySQL必知必会》[06] 触发器

    1.触发器 MySQL中的触发器概念,和Java中的事件监听器有点相似.当你想要某条语句在某个事件发生时自动执行,就要用到触发器了. 触发器能响应如下三类语句: DELETE INSERT UPDAT ...

  9. 3.2《想成为黑客,不知道这些命令行可不行》(Learn Enough Command Line to Be Dangerous)——检查文件开始与结尾

    检查文件两个互补的命令是head 和tail, 它们分别用于查看文件的开始(头部)和结束(尾部).head命令展示了文件的前10行.(Listing 11). ##Listing 11: 查看示例文件 ...

  10. UVA10720 Graph Construction 度序列可图性

    Luogu传送门(UVA常年上不去) 题意:求一个度序列是否可变换为一个简单图.$\text{序列长度} \leq 10000$ 题目看起来很简单,但是还是有一些小细节需要注意首先一个简单的结论:一张 ...