Jump to content

Keep last 9 characters from a string


Recommended Posts

Posted

Hi, I want to keep 9 characters from a string (DText or MText). Thank you so much ! 

Keep_Text.png

Posted

Here is an example:

(setq str "B1-X-(300x200)")
(if (> (setq len (strlen str)) 8)
  (substr str (- len 8))
  )

 

  • Like 1
Posted

A slightly different way, if all the texts are in the format "ABC (NxY)" and where the numbers could be any length. Returns anything after the first '('

 

MyString is the text string to change

 

(if (setq MyPos (vl-string-search "(" MyString)) ; position of deliminator, (
  (setq MyString (substr MyString (+ MyPos 1)) ) ; if contains "("
  MyString                                       ; If doesn't contain "("
)

 

  • Like 2

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...