Wanting clarification for string delimiters

Discussion in 'Ruby' started by Neville Franks, Feb 7, 2007.

  1. %q, %Q, %w, %r, %x all begin a string which terminates with the
    character that matches the character after %q etc. eg. %q[blah] %q/blah/

    But what are the rules for %SomeChar. eg %(blah) works as does %/blah/
    and %+blah+

    However %AblahA doesn't, nor does %1blah1. Does this mean the delimiter
    following % must be a punctuation character? Other than the predefined
    %q etc. listed above of course.

    http://www.zenspider.com/Languages/Ruby/QuickRef.html states:
    ---

    In all of the %() cases below, you may use any matching characters or
    any single character for delimiters. %[], %!!, %@@, etc.

    'no interpolation'
    "#{interpolation}, and backslashes\n"
    %q(no interpolation)
    %Q(interpolation and backslashes)
    %(interpolation and backslashes)
    `echo command interpretation with interpolation and backslashes`
    %x(echo command interpretation with interpolation and backslashes)

    ---

    This says "any single character" etc. which isn't correct in my testing.

    This is for the continuing work I'm doing on adding Ruby syntax to our
    IDE ED4W.

    ---
    Neville Franks, http://www.getsoft.com http://www.surfulater.com

    --
    Posted via http://www.ruby-forum.com/.
    Neville Franks, Feb 7, 2007
    #1
    1. Advertising

  2. Neville Franks schrieb:
    > %q, %Q, %w, %r, %x all begin a string which terminates with the
    > character that matches the character after %q etc. eg. %q[blah] %q/blah/
    >
    > But what are the rules for %SomeChar. eg %(blah) works as does %/blah/
    > and %+blah+
    >

    The delimiter can be any nonalphanumeric or nonmultibyte character.In addition,
    if one of the opening parenthesis characters will be used to start the string,
    the corresposnding closing parenthesis will be uses to finish the string.

    Wolfgang Nádasi-Donner
    Wolfgang Nádasi-Donner, Feb 8, 2007
    #2
    1. Advertising

  3. Neville Franks, Feb 8, 2007
    #3
    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. jt
    Replies:
    3
    Views:
    912
    Keith Thompson
    May 23, 2005
  2. dmitrey
    Replies:
    4
    Views:
    449
  3. Gunter Hansen
    Replies:
    5
    Views:
    917
    Roedy Green
    Sep 1, 2011
  4. Gary C40
    Replies:
    6
    Views:
    142
    MonkeeSage
    Dec 16, 2007
  5. Albert Schlef

    String#split and capturing delimiters

    Albert Schlef, Oct 30, 2009, in forum: Ruby
    Replies:
    3
    Views:
    177
    Rajinder Yadav
    Oct 30, 2009
Loading...

Share This Page