1

我的 jquery 代码现在开始创建一些相当长的代码行,尤其是一些正则表达式字符串。在 Jquery 语法中包装代码行以使其更易于阅读的最佳方法是什么?

谢谢,

4

1 回答 1

2

When dealing with strings you can use concatenation (+) or the backslash (\):

http://www.developfortheweb.com/2009/03/multi-line-strings-in-javascript/

For RegExp you can create them as objects, but you'll need to escape all backslashes.

var REGEX = new RegExp("^\\/[0-9]{1,2}$|^255\\.255\\.255\\.0$");

http://www.regular-expressions.info/javascript.html

于 2012-06-07T13:15:27.460 回答