匹配精确字符串 [英] Match exact string

查看:34
本文介绍了匹配精确字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅当文本完全匹配时才匹配的正则表达式(在 JavaScript 中,如果重要的话)是什么?也就是说,字符串的另一端不应该有多余的字符.

What is the regular expression (in JavaScript if it matters) to only match if the text is an exact match? That is, there should be no extra characters at other end of the string.

例如,如果我试图匹配 abc,然后 1abc11abcabc1> 不匹配.

For example, if I'm trying to match for abc, then 1abc1, 1abc, and abc1 would not match.

推荐答案

使用开始和结束分隔符:^abc$

Use the start and end delimiters: ^abc$

这篇关于匹配精确字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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