Reputation: 16691
My jquery code is now starting to create some pretty long lines of code espically with some of the regex strings. What is the best way to wrap lines of code within your Jquery syntax so that it is easier to read ?
Thanks,
Upvotes: 1
Views: 58
Reputation: 20431
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
Upvotes: 2