tailieunhanh - JavaScript Bible, Gold Edition part 119
JavaScript Bible, Gold Edition part 119. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | 1028 Part IV JavaScript Core Language Reference Syntax Accessing RegExp properties NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 Compatibility About this object Beginning with Navigator 4 and Internet Explorer 4 the browser maintains a single instance of a RegExp object for each window or frame. The object oversees the action of all methods that involve regular expressions including the few related string object methods . Properties of this object are exposed not only to JavaScript in the traditional manner but also to a parameter of the method for some shortcut access see Listing 38-3 . With one RegExp object serving all regular expression-related methods in your document s scripts you must exercise care in accessing or modifying this object s properties. You must make sure that the RegExp object has not been affected by another method. Most properties are subject to change as the result of any method involving a regular expression. This may be reason enough to use the properties of the array object returned by most regular expression methods instead of the RegExp properties. The former stick with a specific regular expression object even after other regular expression objects are used in the same script. The RegExp properties reflect the most recent activity irrespective of the regular expression object involved. In the following listings I supply the long JavaScript-like property names. But each property also has an abbreviated Perl-like manner to refer to the same properties. You can use these shortcut property names in the string .replace method if you need the values. Properties input Value String Read Write NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 Compatibility The property is the main string against which a regular expression is compared in search of a match. In all of the example listings earlier in this chapter the property was null. Such is the case when the main string is supplied as a parameter to the .
đang nạp các trang xem trước