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. DButils实现增删查改

    获取数据库连接 static Connection con=JdbcUtils.MyUtils();//这个连接类静态获取要自己定义 插入 public static void insert() th ...

  2. Objective-C Core Animation深入理解

    Core Animation(核心动画),是从Layer Kit(图层工具包)演变而来的,不仅仅可以用来做动画. 1.视图 一个视图就是屏幕上显示的一个矩形,例如文字.图片和视频. 视图是UIView ...

  3. 【Codeforces Round 1114】Codeforces #538 (Div. 2)

    Codeforces Round 1114 这场比赛做了\(A\).\(C\).\(D\).\(E\),排名\(134\). \(B\)题做了很长时间,好不容易最后一分钟\(Pretest\ Pass ...

  4. 网易云音乐 歌词制作软件 BesLyric (最新版本下载)

    导读 BesLyric , 一款专门制作 网易云音乐 LRC 滚动歌词的软件! 搜索.下载.制作 歌词更方便! 哈哈,喜欢网易云音乐,又愁于制作歌词的童鞋有福啦!Beslyric 为你排忧解难! 本文 ...

  5. you-get帮助使用手册

    you-get使用手册 可选参数:   -V, --version          查看版本并退出   -h, --help             查看帮助信息 不影响使用的选项:   -i, - ...

  6. 使用gulp和bable实现实时编译ES6代码

    这篇文章最初发表在我自己折腾的博客站点上:使用gulp和bable实现实时编译ES6代码,该博客用了一位前辈开源的源码,基于thinkjs和vuejs开发,欢迎大家来逛逛. 问题描述> 项目开发 ...

  7. Luogu3350 ZJOI2016 旅行者 最短路、分治

    传送门 题意:给出一个$N \times M$的网格图,边有边权,$Q$组询问,每组询问$(x_1,y_1)$到$(x_2,y_2)$的最短路.$N \times M \leq 2 \times 10 ...

  8. thymeleaf给bootstrap自定义变量赋值

    最近在做一件事情,前端用的是thymeleaf进行渲染,thymeleaf是通过 th的标签来赋值对应的后端变量的.但是遇到一个尴尬的问题,bootstrap是可以通过data-xxx,来自定义变量的 ...

  9. 发布了一个基于jieba分词的ElasticSearch插件

    github地址: https://github.com/hongfuli/elasticsearch-analysis-jieba 基于 jieba 的 elasticsearch 中文分词插件. ...

  10. Item 9: 比起typedef更偏爱别名声明(alias declaration)

    本文翻译自modern effective C++,由于水平有限,故无法保证翻译完全正确,欢迎指出错误.谢谢! 博客已经迁移到这里啦 我确信我们都同意使用STL容器是一个好主意,并且我希望在Item ...