SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 77 | Next

Jonathan Snook, Aaron Gustafson, Stuart Langridge, and Dan Webb

"Accelerated DOM Scripting with Ajax, APIs, and Libraries"

You can leave out the second parameter to indicate
that the match should start at a minimum number of characters and move up from there (example:
{2,}). The + character matches the character one or more times. The * character matches
the character zero or more times. In the following example, the first line makes sure that there??™s
at least one number in a numbers-only string; the second example could match against an
empty string as well as a string that has one or more numbers in it:
/^\d+$/
/^\d*$/
To remember matches, use round brackets ( ) to remember the match found. In the earlier
date swap example, I??™mtrying to remember three separate matches. In the replace, I can
CHAPTER 2 n HTML, CSS, AND JAVASCRIPT 38
refer to each of the round brackets using a $ followed by a number, which is handy for reordering
the way a string might be put together.
There??™s obviously so much more to regular expressions than what is covered here, so I
highly recommend that you take the time to learn more.
Code Formatting Practices
While there is usually never just one way to do things, it can be important to establish an
approach to coding that makes it clearer for both yourself and others to understand what your
code is trying to accomplish. In this chapter, I have used a particular naming convention for
variables and functions.
JavaScript is commonly written using camel case. Almost all JavaScript APIs, such as the
DOM and XMLHttpRequest, use it.


Pages:
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
Leśmian Bolesław Warszawa Baza nieruchomości kup, s projektowanie stron www Roll up