scala之split()函数用法
split()函数:
def split(arg0: String): Array[String]
def split(arg0: String, arg1: Int): Array[String]
scala> "a-b-c-d-e".split("-",3)
res0: Array[String] = Array(a, b, c-d-e)
scala> "a-b-c-d-e".split("-",4)
res1: Array[String] = Array(a, b, c, d-e)
scala> "a-b-c-d-e".split("-",5)
res2: Array[String] = Array(a, b, c, d, e)
scala> "a-b-c-d-e".split("-",6)
res3: Array[String] = Array(a, b, c, d, e)
scala> "a-b-c-d-e".split("-")
res6: Array[String] = Array(a, b, c, d, e)
scala> "a-b-c-d--e---".split("-")
res7: Array[String] = Array(a, b, c, d, "", e)
//arg1=0,split函数尽可能多的匹配arg0,不保留处于末尾位置的空字符串,空字符串例外。比如:
scala> "--a-b-c-d--e---".split("-")
res8: Array[String] = Array("", "", a, b, c, d, "", e)
scala> "".split("-",0)
res1: Array[String] = Array("")
//arg1<0,保留末尾的空字符串
scala> "--a-b-c-d--e---".split("-",-1)
res0: Array[String] = Array("", "", a, b, c, d, "", e, "", "", "")
scala之split()函数用法的更多相关文章
- perl:split函数用法
本文和大家重点讨论一下Perl split函数的用法,Perl中的一个非常有用的函数是Perl split函数-把字符串进行分割并把分割后的结果放入数组中.这个Perl split函数使用规则表达式( ...
- java split函数用法(转)
1.语法如下 String.split(sourceStr,maxSplit) String.split(sourceStr) 参数说明:sourceStr是被分割的字符串,maxSplit是最大的分 ...
- split函数用法
split函数详解 split翻译为分裂. split()就是将一个字符串分裂成多个字符串组成的列表. split()当不带参数时以空格进行分割,当代参数时,以该参数进行分割. //---当不带 ...
- js中的join(),reverse()与 split()函数用法解析
<script> /* * 1:arrayObject.reverse() * 注意: 该方法会改变原来的数组,而不会创建新的数组.此函数可以将数组倒序排列 * 2:arrayObject ...
- js split函数用法总结
一.split定义:split() 方法用于把一个字符串分割成字符串数组, 返回值: 一个字符串数组. 二.基本用法:stringObject.split(separator,howmany) 1.参 ...
- python中split()、os.path.split()函数用法
一.Python split() 通过指定分隔符对字符串进行切片,如果参数 num 有指定值,则仅分隔 num 个子字符串 str.split(str="", num=string ...
- python 中的os.path.split()函数用法
基本概念 os.path.split()通过一对链表的头和尾来划分路径名.链表的tail是是最后的路径名元素.head则是它前面的元素. 举个例子: path name = '/home/User ...
- Join函数 及Split函数精解示例
'************************************************************************* '**模 块 名:Join函数 及Split函数精 ...
- Python之Split函数
python中的split()函数用来拆分一个字符串,通过指定的分隔符对字符串进行切割,返回切割后的字符串列表list. split()函数用法: str.split(str=' ',num = st ...
随机推荐
- Farm Tour POJ - 2135 (最小费用流)
When FJ's friends visit him on the farm, he likes to show them around. His farm comprises N (1 <= ...
- Insertion Sort Gym - 101955C 思路+推公式
题目:题目链接 题意:对长为n的1到n的数列的前k个数排序后数列的最长上升子序列长度不小于n-1的数列的种数,训练赛时怎么都读不明白这个题意,最后还是赛后问了旁队才算看懂,英语水平急需拯救55555 ...
- 笔记-Python-cProfile
笔记-Python-cProfile 1. 简介python官方提供了cProfile和profile对程序进行性能分析,建议使用cProfile; cProfile:基于lsprof的用C语言实现的 ...
- Spring表达式语言:SpEL
1.Spring表达式语言(简称:SpEL):是一个支持运行时查询和操作对象图的强大的表达式语言. 2.语法类似于EL:SpEL使用#{...}作为定界符,所有在大括号内的字符都被认为是SpEL. 3 ...
- Three Steps to Migrate Group Policy Between Active Directory Domains or Forests Using PowerShell
Three Steps Ahead Have you ever wished that you had three legs? Imagine how much faster you could ru ...
- 试水新的Angular4 HTTP API
本文来自网易云社区 作者:梁月康 原文:https://netbasal.com/a-taste-from-the-new-angular-http-client-38fcdc6b359b Angul ...
- 【Jump Game】cpp
题目: Given an array of non-negative integers, you are initially positioned at the first index of the ...
- c++ primer 读书笔记
顺序容器:为程序提供控制元素存储和访问顺序的能力,这种顺序与元素加入到容器时的位置相对应,而与元素值无关. 另外还有根据关键字的值来存储元素的容器:有序.无序关联容器. 另外STL还有三种容器适配器, ...
- Kernel Space与User Space(转)
对于刚刚接触Linux的菜鸟来说,可能会不理解大家常说的Kernel Space和User Space是什么意思,我简单搜了一下,发现阮一峰写过一个比较简洁的介绍,贴下来给大家: 学习 Linux 时 ...
- mac os 80端口的间接使用
资料显示 MAC OS本质是Unix系统,默认非root用户无法使用1024一下的端口,要是非要用,比如一般情况下,本地项目用tomcat运行,一般都是localhost:8080/XXXX,如果想通 ...