I'm trying to develop a way to represent something that has an URI inside of it, let's say:


where someVariable is alphanumeric.

I just can't figure out what the separator should be, having in mind that it should:

  1. Unambiguously represent a separator
  2. Be small (2 characters, 3 at most)
  3. Be human readable

I've thought of "::", "__", "--" etc, but all are legal in URI (both URNs and URLs are legal in this DSL).

Basically, is there a way of unambiguously determining what is the separator from string containing an URI?


  1. ::
  2. __
  3. --
  4. "##" (breaks if URL ends with #)
  5. Slashes, backslashes
  6. Enclosing with tags, such as <>, {}, works, but then it becomes hard to type; one of the reason it has to be a string. JSON is not an option either.
  • Which characters are allowed in your string representation? – D Drmmr Feb 10 at 12:33
  • URIs and alphanumeric, except the delimiter – Štef FoReal Feb 10 at 14:25
  • So, the symbol should represent it has like we do with UML? Something like -<>, <>- or simpler -< , >-. Regarding :: I have seen these to represent matrixs. – Laiv Feb 10 at 14:26
  • No, not at all. What I want to be able to have a list, space delimited, of strings. Each of these string carries some information inside of them, including an URI. For example: run::urn:google:maps.html::now Where :: is the delimiter, google:maps.html is the URN. – Štef FoReal Feb 10 at 14:30

RFC 3986 lists various reserved characters that have special meaning in any URI, as well as unreserved characters that have no special meaning:

  • general delimiters: : / ? # [ ] @
  • sub-delimiters: ! $ & ' ( ) * + , ; =
  • unreserved/normal: ALPHA DIGIT - . _ ~
  • for percent-encoding: %

This leaves a few ASCII characters unused:

  • double quotes, backticks, pipes, backslashes " ` | \
  • less than/greater than (angled brackets) and curly braces < > { }
  • caret ^
  • spaces, tabs, and unprintable control characters

Appendix C “Delimiting an URI in Context” discusses exactly your problem. The appendix notes that spaces, doublequotes, and angled brackets are common. However, whitespace may be problematic if the URI was wrapped or split for presentational reasons. The RFC concludes:

Using <> angle brackets around each URI is especially recommended as a delimiting style for a reference that contains embedded whitespace.

  • It does not solve my problem, but answers my question. Thanks! – Štef FoReal Feb 10 at 18:33

You mentioned this is a DSL, so it's entirely reasonable for the solution to come from your DSL grammar, rather than finding a general solution for all arbitrary strings-with-URIs-in-then, a much harder problem. You might be able to tackle it in the grammar.

For instance:

  1. Do you always have a single URI in each statement, like in your example? If so, have it the last element. I'm pretty sure the URI scheme element can't contain elements such as #, allowing you to use it as a separator before the URI.

  2. Many characters are valid in URIs but can be represented in several ways. Spaces, for instance, might be represented as a space, a + or %20. You might be able to dictate that URLs in your grammar must encode spaces, and use the actual space character as separator. Alternately, dictate %20 encoding and use +.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.