# What regexp can split a string to argv

**URL:** <https://www.ruby-forum.com/t/what-regexp-can-split-a-string-to-argv/110403>\
**Category:** Ruby\
**Created:** [July 26, 2007, 1:39am UTC](https://www.ruby-forum.com/t/what-regexp-can-split-a-string-to-argv/110403 "2007-07-26T01:39:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![haomiao](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9fc29f/32.png) [@haomiao](https://www.ruby-forum.com/u/haomiao)\
**Post date:** [July 26, 2007, 1:39am UTC](https://www.ruby-forum.com/t/what-regexp-can-split-a-string-to-argv/110403/1 "2007-07-26T01:39:31Z")

</div>

Hi  
I want to split a string to a array like shell doing. And the  
double qote string must be support.  
For example  
'1 2 " 3 4 5" 6 ’ =\> [‘1’, ‘2’, ‘2 4 5’, ‘6’]  
‘1 2 7"3 4 5"6’ =\> [‘1’, ‘2’, ‘72 4 56’]  
Can regexp do this ?  
Or any other way?

---

<div class="post-metadata">

**Author:** ![haomiao](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/9fc29f/32.png) [@haomiao](https://www.ruby-forum.com/u/haomiao)\
**Post date:** [September 25, 2007, 11:03pm UTC](https://www.ruby-forum.com/t/what-regexp-can-split-a-string-to-argv/110403/2 "2007-09-25T23:03:06Z")

</div>

haomiao wrote:

> 

[http://www.ruby-doc.org/core/classes/Shellwords.html](http://www.ruby-doc.org/core/classes/Shellwords.html)
