# Wanting clarification for string delimiters

**URL:** <https://www.ruby-forum.com/t/wanting-clarification-for-string-delimiters/84843>\
**Category:** Ruby\
**Created:** [February 8, 2007, 12:44am UTC](https://www.ruby-forum.com/t/wanting-clarification-for-string-delimiters/84843 "2007-02-08T00:44:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nevf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/97f17d/32.png) [@nevf](https://www.ruby-forum.com/u/nevf)\
**Post date:** [February 8, 2007, 12:44am UTC](https://www.ruby-forum.com/t/wanting-clarification-for-string-delimiters/84843/1 "2007-02-08T00:44:44Z")

</div>

%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](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 F., [http://www.getsoft.com](http://www.getsoft.com) [http://www.surfulater.com](http://www.surfulater.com)

---

<div class="post-metadata">

**Author:** ![nevf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/97f17d/32.png) [@nevf](https://www.ruby-forum.com/u/nevf)\
**Post date:** [February 8, 2007, 1:35am UTC](https://www.ruby-forum.com/t/wanting-clarification-for-string-delimiters/84843/2 "2007-02-08T01:35:07Z")

</div>

On 2/7/07, Neville F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## %(interpolation and backslashes)
> 
> Neville F., [http://www.getsoft.com](http://www.getsoft.com) [http://www.surfulater.com](http://www.surfulater.com)
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

According to the “Programming Ruby” book the delimiter can be any  
nonalphanumeric or nonmultibyte character.

-andy

---

<div class="post-metadata">

**Author:** ![nevf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/97f17d/32.png) [@nevf](https://www.ruby-forum.com/u/nevf)\
**Post date:** [February 8, 2007, 6:41am UTC](https://www.ruby-forum.com/t/wanting-clarification-for-string-delimiters/84843/3 "2007-02-08T06:41:24Z")

</div>

Neville F. 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

---

<div class="post-metadata">

**Author:** ![nevf](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/97f17d/32.png) [@nevf](https://www.ruby-forum.com/u/nevf)\
**Post date:** [February 8, 2007, 6:53am UTC](https://www.ruby-forum.com/t/wanting-clarification-for-string-delimiters/84843/4 "2007-02-08T06:53:39Z")

</div>

Thanks Andy & Wolfgang.

I’m on top of it now and hopefully close to a release. I’ve been feeding  
all the Ruby Library source into ED4W which makes a reasonably good test  
bed for the source database parser and syntax highlighting.

* * *

Neville F., [http://www.getsoft.com](http://www.getsoft.com) [http://www.surfulater.com](http://www.surfulater.com)
