rodrigo_sjc_sp Posted February 21, 2013 Posted February 21, 2013 How to replace this characters / or \ in the string I try (setq usuario (vl-string-subst "" "\\" usuario)) But not is ok, characters don't replace Sample usuario = "TESTE-TE\AAAA\BBBB.x" I need this usuario = "TESTE-TEAAAABBBB.x" Thanks Rodrigo Quote
Tharwat Posted February 21, 2013 Posted February 21, 2013 You want to replace or remove the back slashes ? Quote
rodrigo_sjc_sp Posted February 21, 2013 Author Posted February 21, 2013 I want to remove, More trying to replace for null "" Quote
Lee Mac Posted February 21, 2013 Posted February 21, 2013 _$ (vl-list->string (vl-remove 92 (vl-string->list "TESTE-TE\\AAAA\\BBBB.x"))) "TESTE-TEAAAABBBB.x" _$ (setq str "TESTE-TE\\AAAA\\BBBB.x") "TESTE-TE\\AAAA\\BBBB.x" _$ (while (wcmatch str "*\\*") (setq str (vl-string-subst "" "\\" str))) "TESTE-TEAAAABBBB.x" Quote
Tharwat Posted February 21, 2013 Posted February 21, 2013 This ... ? (setq usuario "TESTE-TE/AAAA\BBBB.x") (setq st (vl-list->string (vl-remove 47 (vl-string->list usuario)))) Quote
rodrigo_sjc_sp Posted February 21, 2013 Author Posted February 21, 2013 (setq usuario (read-line arq)) (setq usuario (vl-string-subst "" "-" usuario)) (setq usuario (vl-string-subst "" "/" usuario)) (setq usuario (vl-list->string (vl-remove 92 (vl-string->list usuario)))) Thanks to all ( Lee and Tharwat ) Quote
Lee Mac Posted February 21, 2013 Posted February 21, 2013 Maybe: (vl-list->string (vl-remove-if '(lambda ( x ) (member x '(45 47 92))) (vl-string->list (read-line arq)))) Quote
togores Posted February 21, 2013 Posted February 21, 2013 Rodrigo, If you wish to replace a substring for another one you can also try: (defun replace (new old string / pos) (while (setq pos (vl-string-search old string pos)) (setq string (vl-string-subst new old string pos) pos (+ pos (strlen new)))) string) Like this: _$ (replace "" "\\" "TESTE-TE\AAAA\BBBB.x") "TESTE-TEAAAABBBB.x" Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.