please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next

 


String.split() Method

Name

String.split() Method---break a string into an array of strings

Availability

Navigator 3.0

Synopsis

string.split();
string.split(delimiter);

Arguments

delimiter

The character or string at which the string will be split. If no delimiter is specified, then the returned array has only one element, the string itself.

Returns

An array of strings, created by splitting string into substrings, at delimiter boundaries.

Description

The split() method creates and returns an array of substrings of the specified string. These substrings are created by splitting the string at every occurrence of the specified delimiter. The delimiter character or characters are not part of the returned substrings.

If no delimiter is specified, then the string is not split at all, and the returned array contains only a single, unbroken string element.

Unfortunately, there is no way to specify more than one delimiter string or character to use. For example, there is no way to tell it to treat any of the space, newline and tab characters as delimiters.

Note that the String.split() method is the inverse of the Array.join() method.

Example

The split() method is most useful when you are working with highly structured strings. For example:

s = "1,2,3,4,5"
a = s.split(",");

Another common use of the split() method is to parse commands and similar strings by breaking them down into words delimited by spaces:

words = sentence.split(' ');

See Also

"Array.join()", "String"


Previous Home Next
String.small() Book Index String.strike()


HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/java/script/definitive/refp_370.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/11/26 19:43,
TOP NEW HELP FIND: 
18.188.140.232:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://ecomorder.com/techref/language/java/script/definitive/refp_370.htm"> [Chapter 21] Reference: String.split()</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .