Jump to content

Recommended Posts

Posted

How do I split a text-code like 2VBG45 or CF34HJ into 2-VBG-45 and CF-34-HJ

What I want to achieve is insert a dash at the place where the text changes from letters to numbers and were it changes from numbers to letters.

The by our customer delivered text-code is always 6 digits but the place/amount of numbers and letters are not always the same. So the total of numbers and letters is always 6 but the amount of letters and numbers in each code can be 2-4 3-3 and 4-2 so there ale always 2 dashes to insert.

Any help will much be appreciated.

Posted
How do I split a text-code like 2VBG45 or CF34HJ into 2-VBG-45 and CF-34-HJ

What I want to achieve is insert a dash at the place where the text changes from letters to numbers and were it changes from numbers to letters.

The by our customer delivered text-code is always 6 digits but the place/amount of numbers and letters are not always the same. So the total of numbers and letters is always 6 but the amount of letters and numbers in each code can be 2-4 3-3 and 4-2 so there ale always 2 dashes to insert.

Any help will much be appreciated.

 

You can try this:

var str = Field("Number"); // Replace with your field name.

var regexStr = str.match(/[a-z]+|[^a-z]+/gi);

return regexStr.join("-");

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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