On Sun, Feb 12, 2012 at 1:34 PM, Don Guinn <dongu...@gmail.com> wrote:
> I think this is close to what you want. It doubles embedded quotes and
> ignores leading and trailing quotes if present. That way one can still
> enter a string which is really supposed have a quote at the begining or
> end. The only real problem is that if one wanted to start or end with a
> quote but forgot to add one extra.
>
> quotes=:3 : 0
> '''' quotes y     NB. Default left argument is quote.
> :
> 'l r'=.x=({.,{:)y NB. Remove leading and trailing quotes if present.
> s=.l}.(-r)}.y
> s=.s#~>:x=s       NB. Double quotes.
> x,s,x             NB. Put leading and trailing quotes back.
> )

   quotes prompt'      '
      'oh', 'really?'
'oh'', ''really?'

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to