跳过范围内的角色(Skip a character in range)

编程入门 行业动态 更新时间:2024-10-17 07:22:36
跳过范围内的角色(Skip a character in range)

我有一个正则表达式: /["-,]/它匹配范围内的字符: to ,我想跳过' (撇号)的匹配。任何帮助!!

regex.test(strInput);

对于带有撇号的字符串,它返回true。 我需要否定那个有撇号的字符串

I have a regular expression : /["-,]/ Which matches a character in range of : to , I want to skip the match for '(apostrophe). Any help !!

regex.test(strInput);

is returning true for a string with an apostrophe. I need to negate that string which has an apostrophe

最满意答案

您可以使用否定前瞻:

/(?!')["-,]/

这里(?!')是负向前瞻 ,这意味着下一个字符不能是单引号。

You can use negative lookahead:

/(?!')["-,]/

Here (?!') is negative lookahead which means next character must not be single quote.

更多推荐

本文发布于:2023-07-14 18:57:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1106680.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:范围内   跳过   角色   range   character

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!