How to use JavaScript strings

Source: Internet
Author: User

  Here are some of the more commonly used methods of using strings, strings are arrays of characters, and in JavaScript, strings are immutable: You can access text anywhere in a string, but JavaScript does not provide a way to modify the contents of a known string.

Common features:

  

1 obj.length Length2  3 Obj.trim () remove whitespace4 Obj.trimleft ()5 obj.trimright)6 Obj.charat (n) returns the nth character in a string7 obj.concat (value, ...) Stitching8 Obj.indexof (Substring,start) sub-sequence position9 Obj.lastindexof (Substring,start) sub-sequence positionTen obj.substring (from, to) gets a subsequence from an index One Obj.slice (start, end) Slice A obj.tolowercase () uppercase - obj.touppercase () lowercase - obj.split (delimiter, limit) split the Obj.search (regexp) matches from the beginning, returning the first position where the match was successful (g invalid) - Obj.match (regexp) Global Search, if there is a G in the regular means find all, otherwise only find the first one.  - Obj.replace (regexp, replacement) is replaced, and g in the regular replaces all, otherwise only the first match is replaced . - $ number: matches the nth group content; +$&: the current matching content; - $ ': text located to the left of the matched substring; +$: Text on the right side of the matching substring A$$: Direct Volume $ symbol

How to use JavaScript strings

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.