Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 24th, 2019, 05:45 AM
macfan55 macfan55 is offline
Junior Community Member
 
Join Date: Apr 2011
Location: Netherlands - Emmen
Posts: 31
Post Insert dash when text-code changes from numbers to letters

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.
Reply With Quote
  #2  
Old January 24th, 2019, 01:18 PM
David Miller David Miller is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Wallingford, CT
Posts: 263
Default Re: Insert dash when text-code changes from numbers to letters

Quote:
Originally Posted by macfan55 View Post
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:
Code:
var str = Field("Number"); // Replace with your field name.

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

return regexStr.join("-");
__________________
David Miller
FusionPro VDP Creator 10.0.26
Adobe Acrobat Pro 2019.008.20074
Suitcase Fusion 20.0.0 (7653)
macOS High Sierra 10.13.6
Reply With Quote
  #3  
Old January 25th, 2019, 06:47 AM
macfan55 macfan55 is offline
Junior Community Member
 
Join Date: Apr 2011
Location: Netherlands - Emmen
Posts: 31
Default Re: Insert dash when text-code changes from numbers to letters

Thanks! that works great!
Reply With Quote
Reply

Tags
dash, letters, numbers, split, text

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:57 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.