匹配精确字符串

问题描述:

仅当文本完全匹配时才匹配的正则表达式(在 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$