Join array elements depending on the element's index
来源:互联网 发布:数据新闻网 编辑:程序博客网 时间:2024/06/15 03:02
I have this array: [ 'here', 'are', 'some', '123', 'data' ]
. I would like to join the elements before the'123'
into a string and the elements after the '123'
into another string to get these three strings:
arr.chunk{|e| (e =~ /\d{3}/) || false}.map{|a| a.last.join(" ")}# => ["here are some", "123", "data"]
0 0
- Join array elements depending on the element's index
- Finding all elements(which are integer) in an array whose sum is equals to the element exists within
- delete the element of array
- Spring Dependencies and Depending on Spring
- On the burstiness of visual elements
- On the burstiness of visual elements
- Check if array element appears on line
- Find the maxest element of an array
- Remove specific element by editing the array
- Check the valid wavefront array index
- The solution on the Elements of Statistical Learning ( Ex. 8)
- the trap: c++'s array
- Conditionally include assemblies depending on Platform setting with MSBuild
- Swap the elements of two sequences, such that the difference of the element-sums gets minimal.
- Find the two non-repeating elements in an array of repeating elements
- How can I combine elements of an array that have a common element?
- python中的element elements
- Armadillo sparse matrix get the index of an element
- 代码中的异常如何处理【未解决】
- debian vnc
- 我在兰亭这三年之升职
- MKMapView上获取自身当前位置并将地图显示范围控制在自身位置周围
- Hibernate,session.save(tu),报错不能将null值插入列id
- Join array elements depending on the element's index
- PHP 安装memcache后,使用时遇到的错误 解决方法
- c++运算符重载
- ubuntu下创建第一个rails应用程序
- 蓝牙常用的profile
- VEH,VCH,UEF Windows向量化异常处理机制详解
- linux 数学运算
- GLog 使用 vs2010
- 推动互联网金融创新,助力深港经济发展