免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1996 | 回复: 5
打印 上一主题 下一主题

split问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-11-23 15:00 |只看该作者 |倒序浏览
$str = "a,b,c,,,";
@getArry = split /,/,$tr;
这样@getArry  里只有a.b.c三个值,得到整个包括后面的空,应该怎么写.请赐教...

论坛徽章:
0
2 [报告]
发表于 2007-11-23 15:17 |只看该作者
@arr = split /,/,$str,-1;

论坛徽章:
0
3 [报告]
发表于 2007-11-23 15:22 |只看该作者
记得好像是split的一个法则吧,如果分割后面全都是空的话,自动舍弃

论坛徽章:
0
4 [报告]
发表于 2007-11-23 15:25 |只看该作者
split /PATTERN/,EXPR,LIMIT

By default, empty leading fields are preserved, and empty trailing ones are deleted.  (If all fields are empty, they are considered to be trailing.)

If LIMIT is negative, it is treated as if an arbitrarily large LIMIT had been specified.  Note that splitting an EXPR that evaluates to the empty string always returns the empty list, regardless of the LIMIT specified.

论坛徽章:
0
5 [报告]
发表于 2007-11-23 15:26 |只看该作者
my @getArry = split /,/, $str, -1;

论坛徽章:
0
6 [报告]
发表于 2007-11-23 15:40 |只看该作者
多谢各位!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP