String.split() Method---break a string into an array of strings
Navigator 3.0
string.split(); string.split(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.
An array of strings, created by splitting string into substrings, at delimiter boundaries.
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.
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(' ');
file: /Techref/language/java/SCRIPT/definitive/refp_370.htm, 6KB, , updated: 2019/10/14 16:00, local time: 2024/8/23 15:21,
3.129.247.37: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? <A HREF="http://piclist.com/tecHREF/language/java/SCRIPT/definitive/refp_370.htm"> [Chapter 21] Reference: String.split()</A> |
Did you find what you needed? |
![]() o List host: MIT, Site host massmind.org, Top posters @none found - Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr. |
Welcome to piclist.com! |
.