Jump to content

Recommended Posts

Posted (edited)

Is it possible to split 1 text into 2 separate texts, based on character "-"?

For example, can I split VAR-259 into

    VAR

    -259

 

Thank you all.

Edited by barristann
Posted

As simple as follows:

(setq str "VAR-259")

(and (setq pos (vl-string-search "-" str))
     (setq pre (substr str 1 pos))     ;; = VAR
     (setq suf (substr str (+ pos 2))) ;; = 259
     )

 

  • Like 1
Posted

I'd go string to List, splits at every character '-' and you can make up the texts to suit from  that

  • Like 1
Posted

Thank you everyone for your guidance.

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