惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
N
Netflix TechBlog - Medium
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V
V2EX
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
M
MIT News - Artificial intelligence
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
Hugging Face - Blog
Hugging Face - Blog
博客园 - 【当耐特】
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
博客园 - 三生石上(FineUI控件)
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
H
Help Net Security
The Cloudflare Blog
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
G
Google Developers Blog
罗磊的独立博客
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
J
Java Code Geeks
A
About on SuperTechFans
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
S
SegmentFault 最新的问题
有赞技术团队
有赞技术团队
GbyAI
GbyAI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
The Register - Security
The Register - Security
U
Unit 42
D
Docker
Martin Fowler
Martin Fowler
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
博客园_首页
Google DeepMind News
Google DeepMind News

博客园 - 福娃

Ubuntu 16.04 LTS更新 程序员如何走出迷茫的困境? PHP vs Python Apache2.4中开通HTTP基本认证 NPM 与 left-pad 事件:我们是不是早已忘记该如何好好地编程? 使用Flask-Migrate进行管理数据库升级 Fabric自动部署太方便了 程序员的复仇:11行代码如何让Node.js社区鸡飞狗跳 CAS认证原理图 grails 私有库相关设置 A successful Git branching model String to Date 多种格式转换 IBatis.Net如何支持多个数据库 [django]the story about Django and TurboGears [django]newforms两种方式示例 Since NHibernate 1.2.0, objects are lazy by default - 福娃 [Castle]Castle.Model被Castle.Core代替了 [Castle]Castle也范型 - 福娃 - 博客园 [Castle]Asp.Net中获取Castle容器中的服务的另一方法
Groovy split竖杆注意
福娃 · 2016-04-05 · via 博客园 - 福娃

前几天将09年写的一个Asp程序使用Grails改造重写,在处理手机号码Split的时候,Asp代码:

dim phoneArr
phoneArr = split(phones,"|")

照搬原来的分割处理,改成Groovy代码如下:

String[] phoneArr = phones.split("|")

但是返回的记过竟然是:

[, 1, 3, 5, 5, 3, 0, 0, 9, 9, 9, 0, |, 1, 3, 5, 0, 0, 4, 3, 2, 3, 1, 1]

最后才发现Groovy split是带正则表达式的,而|符号是正则表达式的特殊字符,最后改成如下即可:

String[] phoneArr = phones.split("\\|")

演示如下: