| Conversion to HTML tags | |
| anchor | Creates an HTML anchor that is used as a hypertext target. |
| big | Causes a string to be displayed in a big font as if it were in a BIG tag. |
| blink | Causes a string to blink as if it were in a BLINK tag. |
| bold | Causes a string to be displayed as if it were in a B tag. |
| fixed | Causes a string to be displayed in fixed-pitch font as if it were in a TT tag. |
| fontcolor | Causes a string to be displayed in the specified color as if it were in a tag. |
| fontsize | Causes a string to be displayed in the specified font size as if it were in a tag. |
| italics | Causes a string to be italic, as if it were in an I tag. |
| small | Causes a string to be displayed in a small font, as if it were in a SMALL tag. |
| link | Creates an HTML hypertext link that requests another URL. |
| strike | Causes a string to be displayed as struck-out text, as if it were in a STRIKE tag. |
| sub | Causes a string to be displayed as a subscript, as if it were in a SUB tag. |
| sup | Causes a string to be displayed as a superscript, as if it were in a SUP tag. |
| String and Substrings | |
| charAt | Returns the character at the specified index. |
| charCodeAt | Returns a number indicating the ISO-Latin-1 codeset value of the character at the given index. |
| concat | Combines the text of two strings and returns a new string. |
| fromCharCode | Returns a string from the specified sequence of numbers that are ISO-Latin-1 codeset values. |
| indexOf | Returns the index within the calling String object of the first occurrence of the specified value. |
| lastIndexOf | Returns the index within the calling String object of the last occurrence of the specified value. |
| match | Used to match a regular expression against a string. |
| replace | Used to find a match between a regular expression and a string, and to replace the matched substring with a new substring. |
| search | Executes the search for a match between a regular expression and a specified string. |
| slice | Extracts a section of a string and returns a new string. |
| split | Splits a String object into an array of strings by separating the string into substrings. |
| substr | Returns the characters in a string beginning at the specified location through the specified number of characters. |
| substring | Returns the characters in a string between two indexes into the string. |
| toLowerCase | Returns the calling string value converted to lowercase. |
| toUpperCase | Returns the calling string value converted to uppercase. |
| valueOf | Returns the primitive value of the specified object. |
Examples:
var sentence = "This is a simple sentence to test the split method."; var words = sentence.split(/\s+|\./); for(i=0;i<words.length;i++) WScript.Echo(words[i]);
var word = "JScript"; for(i=0;i<word.length;i++) WScript.Echo(word.charAt(i));
var address = "home: 123-4556 office: 987-2322 cell: 233-4566 fax: 123-4566";
var phones = address.match(/\d{3}-\d{4}/g);
for(i=0;i<phones.length;i++)
WScript.Echo(phones[i]);
var cardnum = "1234-5678-9012-1213";
var secured = cardnum.replace(/\d{4}-/g, "****-");
WScript.Echo(cardnum + " becomes " + secured);
Please note two things in this example:
var str = "This is a string containing lower and UPPER case characters."; str = str.toLowerCase();