A JavaScript string is separated by commas (,).

Source: Internet
Author: User

A JavaScript string is separated by commas (,).

// Use commas to separate strings and print them into arrays. <! Doctype html> 

How to Use commas to separate strings in jquery

Javascript itself contains the split method.
Definition and usage
The split () method is used to split a string into a string array.
Syntax
StringObject. split (separator, howator)
Parameter description
Separator is required. String or regular expression, which separates stringObject from the specified place.
Optional. This parameter specifies the maximum length of the returned array. If this parameter is set, no more substrings are returned than the array specified by this parameter. If this parameter is not set, the entire string is split, regardless of its length.
Return Value
A string array. This array is created by dividing the string stringObject into substrings at the boundary specified by separator. The strings in the returned array do not include the separator itself.
However, if separator is a regular expression that contains a subexpression, the returned array contains the strings that match the subexpression (but does not include the text that matches the entire regular expression ).

I graduated from Shanghai quanding software college --------

How does javascript split strings by characters?

Var str = '"abc" <123>, "abc" <123> ,';
Var aStr = str. split (',');
AStr. pop ();
Alert (aStr [0]); // "abc" <123>
Alert (aStr [1]); // "abc" <123>

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.