replacing a period in a string using replace
Posted: Fri Feb 18, 2011 6:14 pm
i'm using textexpander on mac os x. the result of the following code is no output. nothing.
I want to replace every occurance of the period {.} with a space " "...
The following code also produces no output:
same:
even if i use #!/usr/bin/newlisp in the prologue of the script, i still get nothing
1. yes i can execute newlisp in the shell with either /usr/bin/newlisp or /usr/bin/env newlisp .
2. yes, the textexpander macro definition type is set to shell script.
the result of evaluating the first code block above in newlisp from the shell when i copy the string "Object.Oriented.Analysis." (without double quotes) is:
the result of evaluating the second code block above in newlisp from the shell when i copy the string "Object.Oriented.Analysis." (without double quotes) is:
the result of evaluating the third code block above in newlisp from the shell when i copy the string "Object.Oriented.Analysis." (without double quotes) is:
^ this seems better, but textexpander produces no output.
Code: Select all
#!/usr/bin/newlisp
(set 'text (exec "pbpaste"))
(replace {\.} text " " 0)
The following code also produces no output:
Code: Select all
#!/usr/bin/env newlisp
(set 'text (string (exec "pbpaste")))
(println (parse (replace {.} text " " 0) ""))
Code: Select all
#!/usr/bin/env newlisp
(set 'text (string (exec "pbpaste")))
(set 'text2 (parse (replace {.} text " ") ""))
(println text2)
(exit)
1. yes i can execute newlisp in the shell with either /usr/bin/newlisp or /usr/bin/env newlisp .
2. yes, the textexpander macro definition type is set to shell script.
the result of evaluating the first code block above in newlisp from the shell when i copy the string "Object.Oriented.Analysis." (without double quotes) is:
Code: Select all
> (set 'text (exec "pbpaste"))
("Object.Oriented.Analysis.")
> (replace "\." text " " 0)
(" ")
Code: Select all
> (set 'text (string (exec "pbpaste")))
"(\"Object.Oriented.Analysis.\")"
> (println (parse (replace {.} text " " 0) ""))
(" ")
(" ")
Code: Select all
> (set 'text (string (exec "pbpaste")))
"(\"Object.Oriented.Analysis.\")"
> (set 'text2 (parse (replace {.} text " ") ""))
("(\"Object Oriented Analysis \")")
> (println text2)
("(\"Object Oriented Analysis \")")
("(\"Object Oriented Analysis \")")