java 分隔函数split("",-1)的用途
转:
java 分隔函数split("",-1)的用途
1.如果字符串最后一位有值,则没有区别,
2.若干最后n位都是切割符,split(" ")不会继续切分,split(" ", -1)会继续切分
- String line = "a b c ";
- String [] tmp = line.split(" ");
- System.out.println(tmp.length+"------");
- for(int i=0;i<tmp.length;i++){
- System.out.println(i+"="+tmp[i]);
- }
- String [] items = line.split(" ",-1);
- System.out.println(items.length+"========");
- for(int i=0;i<items.length;i++){
- System.out.println(i+"="+items[i]);
- }
结果:
4------
0=a
1=b
2=
3=c
13========
0=a
1=b
2=
3=c
4=
5=
6=
7=
8=
9=
10=
11=
12=
- [java] view plain copy
- String line = "a b c d";
- String [] tmp = line.split(" ");
- System.out.println(tmp.length+"------");
- for(int i=0;i<tmp.length;i++){
- System.out.println(i+"="+tmp[i]);
- }
- String [] items = line.split(" ",-1);
- System.out.println(items.length+"========");
- for(int i=0;i<items.length;i++){
- System.out.println(i+"="+items[i]);
- }
结果:
13------
0=a
1=b
2=
3=c
4=
5=
6=
7=
8=
9=
10=
11=
12=d
13========
0=a
1=b
2=
3=c
4=
5=
6=
7=
8=
9=
10=
11=
12=d
java 分隔函数split("",-1)的用途的更多相关文章
- Oracle字符分隔函数(split)
为了让 PL/SQL 函数返回数据的多个行,必须通过返回一个 REF CURSOR 或一个数据集合来完成.REF CURSOR 的这种情况局限于可以从查询中选择的数据,而整个集合在可以返回前,必须进行 ...
- java分割函数split的用法(二)
package com.b; public class Sysetm { public static void main(String[] args) { String a=new String(&q ...
- SQL自定义函数split分隔字符串
SQL自定义函数split分隔字符串 一.F_Split:分割字符串拆分为数据表 Create FUNCTION [dbo].[F_Split] ( @SplitString nvarchar(max ...
- Java中的split函数的用法
Java中的 split 函数是用于按指定字符(串)或正则去分割某个字符串,结果以字符串数组形式返回: 例如: String str="1234@abc"; String[] a ...
- 字符串的分隔方法 split()
java中的split()的方法 string.split([separator,[limit]]) 参数 string (必选),要被分解的 String 对象或文字.该对象不会被 split 方法 ...
- C++常见问题: 字符串分割函数 split
C++标准库里面没有字符分割函数split ,这可太不方便了,我已经遇到>3次如何对字符串快速分割这个问题了.列几个常用方法以备不时之需. 方法一: 利用STL自己实现split 函数(常用,简 ...
- (转)C++常见问题: 字符串分割函数 split
http://www.cnblogs.com/dfcao/p/cpp-FAQ-split.html C++标准库里面没有字符分割函数split ,这可太不方便了,我已经遇到>3次如何对字符串快速 ...
- SQL脚本整理系列一 分隔函数
原来效果: fName Scroe 王某某 ,, 李某某 , 王某某 李某某 李某某 ,, 王某某 执行后效果: name score 李某某 李某某 李某某 王某某 王某某 王某某 王某某 王某某 ...
- hive函数 -- split 字符串分割函数
hive字符串分割函数 split(str, regex) - Splits str around occurances that match regexTime taken: 0.769 secon ...
随机推荐
- MCV 和 MTV框架基本信息
一 . MCV # web服务器开发最著名的MVC模式 M : model.py 就是和数据库打交道的, 创建表等操作 V : view 视图(视图函数,就是装HTML文件的) C : control ...
- Fetch API & Delete & HTTP Methods
Fetch API & Delete & HTTP Methods vue https://developer.mozilla.org/en-US/docs/Web/API/Fetch ...
- Java多线程5:Synchronized锁机制
一.前言 在多线程中,有时会出现多个线程对同一个对象的变量进行并发访问的情形,如果不做正确的同步处理,那么产生的后果就是“脏读”,也就是获取到的数据其实是被修改过的. 二.引入Synchronized ...
- Servlet3.0上传
1.上传对表单限制 *method=post *Enctype=multipart/form-data,它的默认值是:application/x-www-form-urlencoded 表单中需要添加 ...
- Web API 2 Entity Framework 使用 Procedure
Recently I worked on a project, which I started as code first and then I forced to switch to Databas ...
- Military Problem CodeForces 1006E (dfs序)
J - Military Problem CodeForces - 1006E 就是一道dfs序的问题 给定一个树, 然后有q次询问. 每次给出u,k, 求以u为根的子树经过深搜的第k个儿子,如果一个 ...
- A Simple Problem with Integers(线段树区间更新模板)
最基本的线段树的区间更新及查询和 用tag(lazy)数组来“延缓”更新,查询或添加操作必须进行pushdown操作,即把tag从p传到lp和rp并清楚tag[p],既然得往lp和rp递归,那么就可以 ...
- codeforces29A
Spit Problem CodeForces - 29A In a Berland's zoo there is an enclosure with camels. It is known that ...
- django中怎么使用自定义管理后台xadmin
django中怎么使用自定义管理后台xadmin 2018年05月19日 15:48:08 LH_python 阅读数:1001 首先创建基本的django项目,配置好基本的model ,url, ...
- Eclipse 安装Activiti插件(BPMN打开工具)
在Eclipse的菜单中打开help -> install new software: 单击add: Name: Activiti BPMN 2.0 designer Location: htt ...