These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Reformat number into string

Gheezer
Registered: Feb 16 2009
Posts: 19
Answered

I have looked and googled but I'm not having any luck with this problem. I dont' think asking the right question.

How do I convert a number 12345678 into 123-45678?

I've seen something about using this:
var 3dash5 = /^([0-9\s]{0,3})\-?([0-9\s]{0,5})\s*$/;

but I'm not sure how to incorporate it.

Troy

My Product Information:
Acrobat Pro 8.1.1, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
That is a Regular Expression. It's possible to achieve what you want using it, but it's a bit complicated.
You can do it with some simple String manipulation, like so...

var str = "12345678";
var result = str.substring(0,3)+"-"+str.substring(3)

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com