正则表达式/ _ / g是什么意思? [英] What does the regular expression /_/g mean?

查看:397
本文介绍了正则表达式/ _ / g是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

javascript:

javascript:

.replace(/_/g," ");

我的代码中有它,但不记得为什么或它做了什么!你们其中一个正规表达大师能帮忙吗?我知道这可能看起来很基本,但正则表达式不是我的一杯茶,谷歌搜索/ g将无济于事...

I have it in my code but can't remember why or what it does! Can one of you regular expression gurus help? I know this may seem basic, but regular expressions are not my cup of tea, and googling for /g won't help much...

推荐答案

正则表达式匹配 _ 字符。

g 表示全局,并导致替换调用替换所有匹配,而不仅仅是第一个匹配。

The g means Global, and causes the replace call to replace all matches, not just the first one.

这篇关于正则表达式/ _ / g是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆