Home  >  Article  >  Web Front-end  >  How to solve the problem of \[ formatting disorder in regular expressions

How to solve the problem of \[ formatting disorder in regular expressions

一个新手
一个新手Original
2017-09-20 10:00:011823browse

在写csdn博客中,如果一段js代码中存在以下的正则表达式,发布时排版会错乱。如下


当发布出去浏览时,是这样的...


原因就在于"\["。解决方式是通过new RegExp()的方式构建正则表达式对象。

var regex = new RegExp("\\[.{8}\\]", "g");

The above is the detailed content of How to solve the problem of \[ formatting disorder in regular expressions. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn