[Jprogramming] quote problem

Dan Bron j at bron.us
Sun Feb 12 03:34:52 HKT 2012


Oh, just saw Henry's response and he interpreted your question differently.  

If you're not typing these strings in, then what is the source?  And what is processing them (is it ;: ? if it's ". there's more to worry about than proper quoting).

Anyway, if the strings are coming from e.g. a file and the trouble is with parsing them using ;: (instead of evaluating them in the immex session), then you could try something along the lines of  (#~ 2 * '''' = ]) y  (i.e. double singleton quotes).

-Dan

Please excuse typos; composed on a handheld device.

-----Original Message-----
From: Dan Bron <j at bron.us>
Sender: programming-bounces at jsoftware.com
Date: Sat, 11 Feb 2012 14:05:16 
To: Programming forum<programming at jsoftware.com>
Reply-To: Programming forum <programming at jsoftware.com>
Subject: Re: [Jprogramming] quote problem

Unlike C, where \ introduces an escape sequence within string liberals, in J, the only special character in a literal is ' (single quote).

So, to embed quotes in strings, double them up:   a. i. '(`''3'   .  Of course, recursively embedded quotes need quadrupling, octupling, etc (eg 'he said ''she said ''''yes'''', but she lied'', if you can believe that').

The syntax error in your first example is due to the juxtaposition of two nouns, the string  '(`'  and the number 3 .

-Dan


On Feb 11, 2012, at 1:04 PM, "R.E. Boss" <r.e.boss at planet.nl> wrote:

> If I want to process an arbitrary string, I may encounter a string which
> might give a "syntax error" or an "open quote" message.
> 
> How can I detect such a situation and how can I repair the given string?
> 
> 
> 
>   a. i. '(`'3
> 
> |syntax error
> 
> |   a.    i.'(`'3
> 
> 
> 
>   a. i. '(`'3'
> 
> |open quote
> 
> |      a.i.'(`'3'
> 
> |               ^
> 
> 
> 
> 
> 
> R.E. Boss
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


More information about the Programming mailing list