[Jprogramming] regex backreference substition
David Mitchell
davidmitchell at att.net
Fri Jul 9 19:02:46 HKT 2010
On 7/2/2010 20:01, bill lam wrote:
> I want to do
> "s/^let (\w+) = /\t276\t1円\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\t1円\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\t1円\t/' rxs 'craction 2',LF,'let A0 = 123',LF
craction 2
276 A0 123
--
David Mitchell
More information about the Programming
mailing list