Common methods for JavaScript string objects Concise version _ Basics

Source: Internet
Author: User
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 ("Delete line:" +a.strike () + "<br/>");
document.write ("Font size:" +a.fontsize + "<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/>");//This should be "D" document.write ("return Index:" +a.indexof ("F") + "&LT;BR/ > ")//This should be 5 document.write (" Return index (reverse lookup): "+a.lastindexof (" F ") +" <br/> ");//This should be 9 document.write (" Find string: "+ A.search ("F") + "<br/>");//This should be 5, same as IndexOf document.write ("Replacement string:" +a.replace ("a", "a") + "<br/>"); Replace a in the string with a document.write ("Return substring:" +a.slice (1,3) + "<br/>");/BC, return from index 1 to 3-1Substring document.write ("Split string:" +a.split ("D"). ToString () + "<br/>");//D as a separator, split string, return array document.write ("Return substring:" + A.SUBSTR (1,2) + "<br/>")//return substring, starting with index 1, length 2, this is BC document.write ("Return substring:" +a.substring (1,3) + "<br/>"); /Same as Sclice (), return substring of index 1 to 3-1 ("match:" +a.match (/\d+/) + "<br/>");//Regular match, return matching result, here is 32

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.