How to removes the specified characters

Discussion in 'AutoCAD' started by Adesu, Dec 2, 2004.

  1. Adesu

    Adesu Guest

    _$ (vl-remove "a" (list "a" "d" "e" " " "s" "u" "h" "a" "r" "n" "a"))
    ("d" "e" " " "s" "u" "h" "r" "n")
    How to remove not in list,as like "ade suharna",I want to become "de suhrn",any suggest,thanks
     
    Adesu, Dec 2, 2004
    #1
  2. Adesu

    Adesu Guest

    Oops,sorry again
    _$ (setq tex "ade suharna")
    "ade suharna"
    _$ (setq ntex (vl-string-trim "a" (vl-princ-to-string tex)))
    "de suharn"
     
    Adesu, Dec 2, 2004
    #2
  3. Adesu

    Joe Burke Guest

    Hi Ade,

    Suggestion, you don't need vl-princ-to-string here, since the tex symbol refers to a
    string.

    Command: (setq tex "ade suharna")
    "ade suharna"
    Command: (vl-string-trim "a" tex)
    "de suharn"

    Use vl-princ-to-string when a symbol doesn't refer to a string.

    Command: (setq number 123)
    123
    Command: (vl-princ-to-string number)
    "123"
    Command: (setq lst '(1 2 3))
    (1 2 3)
    Command: (vl-princ-to-string lst)
    "(1 2 3)"

    Joe Burke
     
    Joe Burke, Dec 2, 2004
    #3
  4. Adesu

    Adesu Guest

    Hi Joe,thanks a lot for your suggest
     
    Adesu, Dec 3, 2004
    #4
  5. Adesu

    John Uhden Guest

    (defun @cv_strsubst_all (new old what / l n)
    (setq l (strlen new) n 0)
    (while (setq n (vl-string-search old what n))
    (setq what (vl-string-subst new old what n)
    n (+ n l)
    )
    )
    what
    )

    Command: (@cv_strsubst_all "" "a" "ade suharna")
    "de suhrn"
     
    John Uhden, Dec 4, 2004
    #5
  6. Adesu

    Joe Burke Guest

    Hi John,

    Good eye and point taken, "de suhrn" vs. "de suharn".

    Joe Burke
     
    Joe Burke, Dec 5, 2004
    #6
  7. Adesu

    Adesu Guest

    Hi John,thanks a lot too for your advice,it is good idea
     
    Adesu, Dec 6, 2004
    #7
  8. Adesu

    John Uhden Guest

    Glad to be of some help. What's humorous is that I built it four years ago and
    still haven't used it anywhere. :/
     
    John Uhden, Dec 6, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.