On 7/2/2010 20:01, bill lam wrote:
> I want to do
> "s/^let (\w+) = /\t276\t\1\t/"
>
> but j regex (pcre) rxrplc does not product correct result. It seems
> cannot understand \ in the substitution part. replace \t by actual
> value of TAB only solves part of the problem, the backreference \1
> does not take any effect and is regarded as literal '\1'.  What is the
> correct way to do it?
>
> require 'regex'
>
> ('^let (\w+) = ';'\t276\t\1\t') rxrplc 'craction 2',LF,'let A0 = 123',LF
>
> ('^let (\w+) = ';TAB,'276',TAB,'\1',TAB) rxrplc 'craction 2',LF,'let A0 = 
> 123',LF
>

I tried this:

http://www.jsoftware.com/jwiki/Scripts/Regular Expressions Substitution

    load 'c:\users\me\j602-user\projects\regexs.ijs'
    '/^let (\w+) = /\t276\t\1\t/' rxs 'craction 2',LF,'let A0 = 123',LF
craction 2
        276     A0      123
--
David Mitchell
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to