Jump to content

Basic - replace characters using vl-string-subst ( / or \)


Recommended Posts

Posted

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

Posted

I want to remove,

 

More trying to replace for null ""

Posted
_$ (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"

Posted

This ... ?

 

(setq usuario "TESTE-TE/AAAA\BBBB.x")

(setq st (vl-list->string (vl-remove 47 (vl-string->list usuario))))

Posted

 (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 ) ;)

Posted

Maybe:

(vl-list->string (vl-remove-if '(lambda ( x ) (member x '(45 47 92))) (vl-string->list (read-line arq))))

Posted

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"

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...