admin管理员组文章数量:1394217
I'm attempting to build a regular expression (in JavaScript) that would match = but not !=, <=, >=, '= and ==. I've figured out everything but ==:
text.match(/[^!<>']=/) != null
I've failed everything I've tried to ignore ==. Would anyone be able to help?
I'm attempting to build a regular expression (in JavaScript) that would match = but not !=, <=, >=, '= and ==. I've figured out everything but ==:
text.match(/[^!<>']=/) != null
I've failed everything I've tried to ignore ==. Would anyone be able to help?
Share Improve this question asked Jul 29, 2013 at 22:59 eliajfeliajf 4957 silver badges16 bronze badges 02 Answers
Reset to default 3You could use something like this, which also allows the equal sign to be at the very beginning or at the very end of your string:
/(^|[^!><'=])=($|[^=])/
but note that the matching result will contain the characters to the left and to the right of the equal sign, if there are any.
text.match(/[^=<>!']=[^=]/)
本文标签: javascriptUsing Regular Expressions to match single equals sign onlyStack Overflow
版权声明:本文标题:javascript - Using Regular Expressions to match single equals sign only - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744757408a2623544.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论