Mountain_XD Posted November 29, 2023 Share Posted November 29, 2023 Hi, I want to keep 9 characters from a string (DText or MText). Thank you so much ! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 29, 2023 Share Posted November 29, 2023 Here is an example: (setq str "B1-X-(300x200)") (if (> (setq len (strlen str)) 8) (substr str (- len 8)) ) 1 Quote Link to comment Share on other sites More sharing options...
Steven P Posted November 29, 2023 Share Posted November 29, 2023 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 "(" ) 2 Quote Link to comment Share on other sites More sharing options...
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.