// Crt_strtok.c // compile with:/W3 // in this program, a loop uses strtok // to print all the tokens (separated by commas // or blanks) in the string named "string ". // # include # include char string [] = "a string \ TOF, tokens \ NAND some
Wrote a simple version of the split string1 Private StaticString[] Mysplit (Char[] myString,Charc) {2 //TODO Auto-generated method stubs3 intcount=0;///Statistics The number of occurrences of the split symbol4 ///First
Sometimes it is necessary to partition the irregular data, the data may appear one or more different separators, then need to use the String.Split () method to split, the code is as follows: String string = "Zhang San: John Doe, Harry; Zhao Liu:
Experience Sharing:1, the delimiter is "." (No output), "|" (Cannot get the correct result) when the escape character, "*", "+" when an error throws an exception, must be preceded by adding "\ \", such as split (\\|);2, if "\" as a separate, you
Knowledge Supplement
The split method of string supports regular expressions;
The regular expression \s represents any white space character that matches + one or more occurrences.
With the above supplementary knowledge, the
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
Java class, split with "," to convert a string to an arrayString str = "A,b,c,";string[] arr = Str.split (",");System.out.println (arr.length);The output length is 3,arr[0]= "a"; Arr[1]= "B"; Arr[2]= "C";JS, to "," split, the string is converted to
var str_componets = "I like Swift"Str_componets.componentsseparatedbystring ("")In this way, the str_componets is divided into four sections:["I", "like", "Swift", "" ")You can also use Nscharacterset to split:var str_componets = "I would prefer a
Bind the string to the input stream Istringstream, and then use the third parameter of getline to customize what symbol to use to split it.#include #include#includestring>#includeusing namespacestd;voidSplitConst string& s,vectorint>& SV,Const
The explode () function can be used to split character functions in PHP, but there must be a rule for using this function, such as separating the | or by other characters, so that we can use the explode to divide the string into an array and then
Source http://java2000-net.iteye.com/blog/242162
First look at the source code Java code/** * * @author Zhaoqing www.java2000.net * * * * clas s T {public static void main (string args[]) {string num[] = new STRING[11]; String sline
Example of data sampleSecond, split single lineSELECTId_,regexp_substr (Name_,'[^,]+',1, rownum) H2 from(SelectId_,name_ fromTest_reg_count TwhereT.id_=2) CONNECT by Level Length (name_)-LengthReplace(Name_,',',"'))+1;--orSELECTId_,regexp_substr
Use [datachange]go/****** Object: userdefinedfunction [dbo].[ F_SPLITSTR] Script date:05/09/2016 15:04:21 Modify the database name yourself, and execute it directly ******/set ansi_nulls ongoset quoted_identifier ongoalter FUNCTION [dbo].
This function splits the target string with the specified string and returns the result through the table structure. The code is as follows:CREATE OR REPLACETYPE Str_split is TABLE of VARCHAR2(4000);CREATE OR REPLACE FUNCTIONSplitstr (p_stringinch
Public class stringsplit { public static void main (String [] args) { String sourceStr = " 1,2,3,4,5 "; string[] sourcestrarray = Sourcestr.split (","); for (int i = 0; i Output Result: 2413,4,5 Split's implementation
Because C + + string does not have the split function, so the string division of words must be written by themselves, it is equivalent to implement a split function it!If you need to split the word according to a single character, it is good to read
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.