Dawn McAtee wrote:
Hi,
I have a rule for the formatted number called FormatTollFree
My line of text looks like:
Toll Free:  (tab) +1 713 775 9191
How would I write the rule to get the Toll Free: (tab) +1 to suppress plus
include the rule to format the number?

I used to use resources, but it would be nice if I could include everything
in the rule.
Thanks
Dawn

// This rule allows the user to enter a phone number in any format they want and then have FusionPro Re-format the number according to your preferences. Also this rule will tab over to the formatted number and suppress the entire line if a phone value is not entered. Change the Red text to match your Building Block Field. Copy The following rule into into a new Empty Rule and check Treat returned strings as tagged text..The rule should do everything that you need done.A brief description on how to use the rule is below. // To define the separator characters (between the area code, exchange, and number) simply type the character // between the $1, $2, and $3 in the first six lines of code. By default, the separattor character is a decimal (.).Copy Rule:



var formatStyle01 = "+1 $1 $2";    //simple 7 digit phone

var formatStyle02 = "+1 $1 $2 $3";   //simple 10 digit phone

var formatStyle03 = "+$1 $2 $3 $4";  //10 digit phone starts with 1

var formatStyle04 = "+1 $1 $2 $3 ext.$4";  //10 digit phone with extension

var formatStyle05 = "+$1 $2 $3 $4 ext.$5"; //10 digit phone starts with 1 with extension

var formatStyle06 = "+1 $1 $2 ext.$3";  //7 digit phone with extension

var formatStyle07 = "+1 $1 $2";    //7 digit phone can end in non-digits

var formatStyle08 = "+1 $1 $2 ext.$3"; //7 digit phone can end in non-digits with ext

var formatStyle09 = "+1 $1 $2 $3"; //7 digit phone can end in non-digits starts with 1

var formatStyle10 = "+1 $1 $2 $3 ext.$4"; //7 digit phone can end in non-digits with ext starts with 1



var thisNumber =Field("Office");



//////////////////////////////////////////////////////////////////////////////////////////////////////

// DO NOT EDIT BELOW THIS LINE ///////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////////



return formatNumber(Trim(thisNumber));



function formatNumber(number01){



var pattern01 = /^(\d{3})[^\w]*(\d{4})$/; // 2201727 or 220-1727 or 220- 1727

var pattern02 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/; // 8002201727 or 800-220-1727 or (800)220-1727 or (800) 220-1727

var pattern03 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/; // 18002201727 or 1-800-220-1727 or +1 (800) 220-1727

var pattern04 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; // 800-220-1727 ext 12345 or (800) 220-1727 ext 12345

var pattern05 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; // 1-800-220-1727 ext 12345 or +1 (800) 220-1727 ext 12345

var pattern06 = /^(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; // 2201727 ext 1234 or 220-1727 ext 1234 or 220- 1727 ext 1234



var pattern07 = /^(\d{3})[^\d]*(\w{7})$/; // 800LETTERS or 800-LETTERS or 800- LETTERS

var pattern08 = /^(\d{3})[\D]*(\w{7})\D*[x#n]\D*(\d+)$/; // 800LETTERS ext 1234 or 800-LETTERS ext 1234 or 800- LETTERS ext 1234

var pattern09 = /^\+?(\d{1})[\D]*(\d{3})[^\d]*(\w{7})$/; // 1800LETTERS or 1-800-LETTERS or +1 (800) LETTERS

var pattern10 = /^\+?(\d{1})[\D]*(\d{3})[^\d]*(\w{7})\D*[x#n]\D*(\d+)$/; // 1-800-LETTERS ext 12345 or +1 (800) LETTERS ext 12345



var patternEndExt = /(.)[x#n](.)/;

var patternStart1 = /^[\D]*[1]/;



if(number01.match(pattern01)){

 number01 = number01.replace(pattern01, formatStyle01);

 return number01;

} else if(number01.match(pattern02)){

 number01 = number01.replace(pattern02, formatStyle02);

 return number01;

} else if(number01.match(pattern03)){

 if (number01.match(patternStart1)){

  number01 = number01.replace(pattern03, formatStyle03);

  return number01;

 } else {

  number01 = number01.replace(pattern06, formatStyle06);

  return number01;

 }

} else if(number01.match(pattern04)){

  number01 = number01.replace(pattern04, formatStyle04);

  return number01;

} else if(number01.match(pattern05)){

  number01 = number01.replace(pattern05, formatStyle05);

  return number01;

}  else if(number01.match(pattern06)){

  number01 = number01.replace(pattern06, formatStyle06);

  return number01;

} else if(number01.match(pattern07)){

  number01 = number01.replace(pattern07, formatStyle07);

  return number01;

} else if(number01.match(pattern08)){

 if(number01.match(patternStart1)){

  number01 = number01.replace(pattern10, formatStyle10);

  return number01;

 } else {

  number01 = number01.replace(pattern08, formatStyle08);

  return number01;

 }

} else if(number01.match(pattern09)){

  number01 = number01.replace(pattern09, formatStyle09);

  return number01;

} else if(number01.match(pattern10)){

  number01 = number01.replace(pattern10, formatStyle10);

  return number01;

} else {

 //return "no match any pattern";

 return number01;

}

}

if (Field("Phone") == "")

return "";

else

return 'Toll Free:'+"<t>"+formattednumber;

--
Nicola DosSantos

Ambit Press / Minuteman Press of Cambridge
Five Cambridge Center
Cambridge, MA 02142
Tel: 617.876.3688 Fax: 617.876.3896 www.ambitpress.com

Please send all jobs to [EMAIL PROTECTED]



+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- Calling all FP Web Users!

Do you have a question or lots of knowledge to share about FusionPro Web?

If so, join our Printable Web to Print Users' Forum today!

Send email to [EMAIL PROTECTED] to find out how! +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-


--
Users of FusionPro Desktop have unlimited free email support. Contact Printable Support at [EMAIL PROTECTED] --
View FusionPro Knowledge Base, FusionPro Samples at
www.printable.com/vdp/desktop.htm

--
You are currently subscribed to fusionpro as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
--


--
Note:  All e-mail sent to or from this address will be received or otherwise 
recorded by the e-mail recipients of this forum. It is subject to archival, 
monitoring or review by, and/or disclosure to someone other than the recipient. 
Our privacy policy is posted on www.printplanet.com
--

Reply via email to