JavaScript string manipulation

Source: Internet
Author: User

CharAt (n)//returns the character of the specified position (n) 

    var str= "ABCDEFGE";
Console.log (Str.charat (3)); Output d

IndexOf (s,n)//Returns the position of the s first word backward from the position of n

    var str= "ABCDEFGE";

Console.log (Str.indexof ("E", 0)); Output 4
Console.log (Str.indexof ("E", 4)); Output 4
Console.log (Str.indexof ("E", 5)); Output 7

LastIndexOf (s,n)//Find s from N position forward

     var str= "ABCDEFGE";

Console.log (Str.lastindexof ("E", 7)); Output 7

toLowerCase ()//convert string to lowercase 

var strr= "ABC";
Console.log (Strr.tolowercase ()); Output ABC

toUpperCase ()//convert string to uppercase  

var ast= "abc";
Console.log (Ast.touppercase ()); Output ABC

Slice (A, B)//extract and return the characters between a

     var str= "ABCDEFGE";

Console.log (Str.slice (2,3)); Output C

Split ("", N)//conditionally intercepts the character and converts it to a string (preceded by a condition, followed by a few characters conversion)

Replace (Regular)//convert the specified string to ...

JavaScript string manipulation

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.