function *replace* could not catch $0, $1 in Ubuntu 14.04

For the Compleat Fan
Locked
ssqq
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

function *replace* could not catch $0, $1 in Ubuntu 14.04

Post by ssqq »

When I test *repace* in ubuntu 14.04, I found following test would fail:

(set 'str "---axb--ayb---")
(replace "(a)(.)(b)" str (append $3 $3 $1) 0)
(= str "---bxa---bya---")

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: function *replace* could not catch $0, $1 in Ubuntu 14.0

Post by Lutz »

Look at your code again. You probably mean:

Code: Select all

> 
(set 'str "---axb--ayb---")
(replace "(a)(.)(b)" str (append $3 $2 $1) 0)
(= str "---bxa--bya---")

"---axb--ayb---"
"---bxa--bya---"
true
> 

ssqq
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

Re: function *replace* could not catch $0, $1 in Ubuntu 14.0

Post by ssqq »

yes, I write error code.

I found the int-option in replace is could not ignore like *regex*. if ignore the int-option, newLISP would make "find-str" as *literal str*, if add int-option, newLISP would treat *find-str* as *regex-str".

(replace "(a)" "aabb" "c")
=> "aabb"
> (replace "(a)" "aabb" "c" 0)
=> "ccbb"

Locked