Jump to content

Split 1 Text into 2


barristann

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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