Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > what regexp can split a string to argv

Reply
Thread Tools

what regexp can split a string to argv

 
 
haomiao
Guest
Posts: n/a
 
      07-25-2007
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?

 
Reply With Quote
 
 
 
 
Tim Hunter
Guest
Posts: n/a
 
      07-25-2007
haomiao wrote:
> 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?
>
>
>

http://www.ruby-doc.org/core/classes/Shellwords.html

--
RMagick OS X Installer [http://rubyforge.org/projects/rmagick/]
RMagick Hints & Tips [http://rubyforge.org/forum/forum.php?forum_id=1618]
RMagick Installation FAQ [http://rmagick.rubyforge.org/install-faq.html]


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use String.split to split a mixed encoding string(partencoded in gbk, part encoded in utf-8) Stanley Xu Ruby 2 03-23-2011 02:06 PM
[regexp] How to convert string "/regexp/i" to /regexp/i - ? Joao Silva Ruby 16 08-21-2009 05:52 PM
String#split(/\s+/) vs. String#split(/(\s+)/) Sam Kong Ruby 5 08-12-2006 07:59 PM
difference(s) between char** argv and char* argv[] David C Programming 10 09-15-2003 06:58 AM
char **argv vs. char* argv[] Bret C Programming 21 09-03-2003 03:24 AM



Advertisments