what regexp can split a string to argv

Discussion in 'Ruby' started by haomiao, Jul 25, 2007.

  1. haomiao

    haomiao Guest

    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?
    haomiao, Jul 25, 2007
    #1
    1. Advertising

  2. haomiao

    Tim Hunter Guest

    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]
    Tim Hunter, Jul 26, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bret

    char **argv vs. char* argv[]

    Bret, Aug 31, 2003, in forum: C Programming
    Replies:
    21
    Views:
    4,558
    Richard Heathfield
    Sep 3, 2003
  2. David
    Replies:
    10
    Views:
    5,924
    Richard Heathfield
    Sep 15, 2003
  3. Sam Kong
    Replies:
    5
    Views:
    228
    Rick DeNatale
    Aug 12, 2006
  4. Joao Silva
    Replies:
    16
    Views:
    342
    7stud --
    Aug 21, 2009
  5. Stanley Xu
    Replies:
    2
    Views:
    591
    Stanley Xu
    Mar 23, 2011
Loading...

Share This Page