首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >处理数组中的元素

处理数组中的元素
EN

Stack Overflow用户
提问于 2014-06-17 03:13:27
回答 1查看 33关注 0票数 0

所以我有一个名为match的数组,其中match[0] =

代码语言:javascript
复制
[2014-05-30 15:21:20,781] DEBUG [scheduler-4] (DiamondSchedulerRunner.java:41) Current node is not a manager of:publishEmail in tenant:0 
[2014-05-30 15:21:20,781] DEBUG [scheduler-1] (DiamondSchedulerRunner.java:41) Current node is not a manager of:readEmail in tenant:0 
[2014-06-11 10:18:51,370] ERROR [executorWithPoolSizeRange-5] (PushNotificationsServiceBean.java:140) cannot send notification: service Whaler is not available for user himanshu.taunk@hp.com on device Desktop.device.uuid813374 
[2014-05-30 15:21:50,608] DEBUG [scheduler-3] (DiamondSchedulerProxy.java:96) Diamond Scheduler name:index Mode:TENANT_NODE runOnTenant:true split:true 
[2014-05-30 15:21:50,624] DEBUG [scheduler-3] (DiamondSchedulerRunner.java:41) Current node is not a manager of:index in tenant:0 
[2014-06-11 10:18:49,124] ERROR [executorWithPoolSizeRange-5] (PushNotificationsServiceBean.java:140) cannot send notification: service Whaler is not available for user himanshu.taunk@hp.com on device Desktop.device.uuid798084 
[2014-05-30 15:21:50,780] DEBUG [scheduler-5] (DiamondSchedulerProxy.java:96) Diamond Scheduler name:snooze Mode:TENANT_NODE runOnTenant:true split:true 
[2014-05-30 15:21:50,780] DEBUG [scheduler-5] (DiamondSchedulerRunner.java:41) Current node is not a manager of:snooze in tenant:0 
[2014-05-30 15:21:50,796] ERROR [scheduler-4] (DiamondSchedulerProxy.java:96) Diamond Scheduler name:publishEmail Mode:TENANT_NODE runOnTenant:true split:true 

match[1]是时间戳,match[2]是状态,match[3]是线程名,依此类推。有没有什么办法可以颠倒第一个索引中的元素,match[0],使得第一行成为最后一行,反之亦然,而不会扰乱其他索引?

更好的是,我可以逐行读取第一个索引到另一个数组中,然后反转后一个数组吗?

EN

回答 1

Stack Overflow用户

发布于 2014-06-17 07:25:09

你能用分隔符拆分匹配,\n然后反转并加入吗?即

代码语言:javascript
复制
match[0] = match[0].split('\n').reverse().join('\n')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24250551

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档