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

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

问题描述

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

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天全站免登陆