当前位置:网站首页>JS use regular expressions in g model and non g difference
JS use regular expressions in g model and non g difference
2022-08-10 22:41:00 【Breeze and drizzle_Linmumu】
Meaning
g is the abbreviation of global!It is to match all matching results.
- Without g, in the regular process, the string is matched from left to right, if the match is successful, it will not continue to match to the right;
- With g, it will pick out the correct matching string from beginning to end
Instance
var str = 'aaaaaaaa'var reg1 = /a/var reg2 = /a/gstr.match(reg1) // The result is: ["a", index: 0, input: "aaaaaaaa"]str.match(reg2) // The result is: ["a", "a", "a", "a", "a", "a", "a", "a"]
边栏推荐
- 虚拟地址空间
- 异常的了解
- 华为HCIE云计算之Fusion Access桌面云
- H3C S5130 IRF做堆叠
- String类的常用方法
- c语言之 练习题1 大贤者福尔:魔法数,神奇的等式
- 2022.8.8 Selected Lectures on Good Topics (Number Theory Field)
- 谁是边缘计算服务的采购者?是这六个关键角色
- Detailed installation steps and environment configuration of geemap
- LeetCode Daily 2 Questions 01: Reverse Strings (both 1200) Method: Double Pointer
猜你喜欢
2022年8月的10篇论文推荐
ThreadLocal全面解析(一)
威纶通触摸屏如何在报警的同时,显示出异常数据的当前值?
shell脚本循环语句for、while语句
企业云存储日常运行维护实践经验分享
Conditional Statements of Shell Programming (2)
Redis Performance Impact - Asynchronous Mechanisms and Response Latency
shell(文本打印工具awk)
Common interview questions for APP UI automation testing, maybe useful~
12 Recurrent Neural Network RNN2 of Deep Learning
随机推荐
VLAN huawei 三种模式
Black cat takes you to learn Makefile Part 12: Summary of common Makefile problems
String类的常用方法
链表中的节点每k个一组翻转
STL-deque
财务年报怎样翻译,为什么要选择专业翻译公司?
Why general company will say "go back messages such as" after the end of the interview, rather than just tell the interviewer the result?
IM 即时通讯开发如何设计图片文件的服务端存储架构
LeetCode Daily 2 Questions 01: Reverse Strings (both 1200) Method: Double Pointer
How to translate financial annual report, why choose a professional translation company?
Use Cloudreve to build a private cloud disk
阿里云张新涛:支持沉浸式体验应用快速落地,阿里云云XR平台发布
水果沙拉酱
一篇文章教你Pytest快速入门和基础讲解,一定要看
【640. Solving Equations】
【640. 求解方程】
Self-organization is a two-way journey between managers and members
FPGA - 7系列 FPGA内部结构之Memory Resources -03- 内置纠错功能
文件IO-缓冲区
如何成为一名正义黑客?你应该学习什么?