Strange split with parentheses in Regexp

Discussion in 'Ruby' started by Oliver Cromm, May 26, 2005.

  1. Oliver Cromm

    Oliver Cromm Guest

    I just stumbled over the following effect and (trial-and error)
    workaround:

    p "abcxyxyxydef".split(/(xy)+/) #=> ["abc","xy","def"]
    p "abcxyxyxydef".split(/(?:xy)+/) #=> ["abc","def"]

    Why this difference?
    --
    Microsoft designed a user-friendly car:
    instead of the oil, alternator, gas and engine
    warning lights it has just one: "General Car Fault"
     
    Oliver Cromm, May 26, 2005
    #1
    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. Max Williams
    Replies:
    8
    Views:
    107
    Max Williams
    Oct 9, 2007
  2. Joao Silva
    Replies:
    16
    Views:
    366
    7stud --
    Aug 21, 2009
  3. Emil Kampp
    Replies:
    11
    Views:
    166
    Robert Klemme
    Mar 26, 2011
  4. Jane Doe
    Replies:
    3
    Views:
    138
    Jane Doe
    Sep 13, 2003
  5. weston
    Replies:
    1
    Views:
    94
    Michael Winter
    Jun 28, 2005
Loading...

Share This Page