This article will introduce the usage of string objects in detail. If you need to know about js string objects, you will not be able to refer to them.
| The Code is as follows: |
Copy code |
Var a = "abcDEfGgdefg32asdf38 "; Document. write ("Original:" + a + "<br/> ") Document. write ("bold:" + a. bold () + "<br/> "); Document. write ("large:" + a. big () + "<br/> "); Document. write ("italic:" + a. italics () + "<br/> "); Document. write ("strikethrough:" + a. strike () + "<br/> "); Document. write ("font size:" + a. fontsize (10) + "<br/> "); Document. write ("font color:" + a. fontcolor ("# ff0000") + "<br/> "); Document. write ("superscript:" + a. sup () + "<br/> "); Document. write ("subscript:" + a. sub () + "<br/> "); Document. write ("uppercase:" + a. toUpperCase () + "<br/> "); Document. write ("uppercase:" + a. toLowerCase () + "<br/> "); Document. write ("Return Index character:" + a. charAt (3) + "<br/>"); // Here it should be "D" Document. write ("Return Index:" + a. indexOf ("f") + "<br/>"); // Here it should be 5 Document. write ("Return Index (reverse search):" + a. lastIndexOf ("f") + "<br/>"); // Here it should be 9 Document. write ("search string:" + a. search ("f") + "<br/>"); // Here it should be 5, the same as indexOf Document. write ("replacement string:" + a. replace ("a", "A") + "<br/>"); // replace a with Document. write ("Return substring:" +. slice () + "<br/>"); // It should be bc and return the substring from Index 1 to 3-1. Document. write ("split string:" +. split ("D "). toString () + "<br/>"); // uses D as the delimiter, splits the string, and returns an array. Document. write ("Return substring:" +. substr () + "<br/>"); // return the substring, starting from Index 1. The length is 2. Here it is bc. Document. write ("Return substring:" +. substring () + "<br/>"); // same as sclice (), returns the substring from 1 to 3-1. Document. write ("match:" + a. match (/d +/) + "<br/>"); // regular match, returns the matching result, which is 32
|