kenstraker Posted September 23, 2014 Share Posted September 23, 2014 Hi I am creating an business card i need to format the mobile number to lets say 7780 888 999 i have tried using the built in format number rule but these all seems to be US format can this be done for UK? i cant seem to make this work. Regards Quote Link to comment Share on other sites More sharing options...
dreimer Posted September 23, 2014 Share Posted September 23, 2014 You could try this return Left(Field("YOURFIELD"),4)+" "+Left(Right(Field("YOURFIELD"),6),3)+" "+Right(Field("YOURFIELD"),3) I didn't test it, but this is assuming all need to be formatted the same as how you posted. Quote Link to comment Share on other sites More sharing options...
David Miller Posted September 24, 2014 Share Posted September 24, 2014 (edited) Assuming your data is always in a 4-3-3 digit format, 12 characters total, you will need to make minor changes to Don's suggestion, in red, below. return Left(Field("YOURFIELD"),4)+" "+Left(Right(Field("YOURFIELD"),[color="red"]7[/color]),3)+" "+Right(Field("YOURFIELD"),3)[color="Red"];[/color] Taking this approach and depending on your data, you might want to strip out the spaces first. You could try: var str = Field("YourField");//Replace with your field name var newStr = str.replace(/\s+/g, ''); return Left(newStr,4) + " " + Left(Right(newStr,6),3) + " " + Right(newStr,3); Or maybe, strip out spaces and hyphens first. Additions are in red: var str = Field("YourField");//Replace with your field name var newStr = str.replace(/\s+[color="red"]|-[/color]/g, ''); return Left(newStr,4) + " " + Left(Right(newStr,6),3) + " " + Right(newStr,3) et cetera... There are probably more efficient ways of accomplishing this. Edited September 25, 2014 by David Miller Quote Link to comment Share on other sites More sharing options...
kenstraker Posted September 24, 2014 Author Share Posted September 24, 2014 Thanks very much David/Dreimer for your help that is exactly what I need to achieve. Cheers Guys Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.