String split (), string split

Source: Internet
Author: User

String split (), string split

Knowledge:

The split () method splits the string into a string array and returns this array.

Syntax:
StringObject. split (separator, limit)
Parameter description:

 

Note:If an empty string ("") is used as a separator, each character in the stringObject is separated.

We will split the string in different ways:

Use the specified symbol to split the string. The Code is as follows:

Var mystr = "www.imooc.com"; document. write (mystr. split (". ") +" <br> "); document. write (mystr. split (". ", 2) +" <br> ");

Running result:

Www, imooc, comwww, imooc

Split the string into characters. The Code is as follows:

Document. write (mystr. split ("") + "<br>"); document. write (mystr. split ("", 5 ));

Running result:

W,., I, m, o, o, c,., c, o, mw, w, w,., I

 

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.