JavaScript对象:JavaScript RegExp n$ 量词

返回到:JavaScript对象:JavaScript RegExp 对象

定义和用法

n$ 量词匹配任何结尾为 n 的字符串。

语法

new RegExp("n$")

或者

/n$/

实例

对字符串结尾的 “is” 进行全局搜索:

var str="Is this his";
var patt1=/is$/g;

DEMO:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Web176教程(Web176.com)</title>
</head>
<body>

<script>
var str="Is this his";
var patt1=/is$/g;
document.write(str.match(patt1));

</script>
</body>
</html>

作者:terry,如若转载,请注明出处:https://www.web176.com/javascriptbook/jsarrtips/2889.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2021年8月9日 下午5:11
下一篇 2021年8月9日 下午5:20

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注