AS3格式化英国移动电话号码(XXXXXXXXXX)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AS3格式化英国移动电话号码(XXXXXXXXXX)相关的知识,希望对你有一定的参考价值。
This returns a string with a single space after the fifth character.Useful for displaying a UK mobile number which is easy to read.
function formattedMobileNum($numStr:String):String { var withNoSpaces:String = $numStr.split(" ").join(""); var part1:String = withNoSpaces.substr(0, 5); var part2:String = withNoSpaces.substr(5, withNoSpaces.length-1); var formatted = part1 + " " + part2; formatted = formatted.replace(/^s+|s+$/g, ""); return formatted; } var mobileNum:String = " 0 785 41 23 456 "; trace(formattedMobileNum(mobileNum)); // OUTPUT // 07854 123456
以上是关于AS3格式化英国移动电话号码(XXXXXXXXXX)的主要内容,如果未能解决你的问题,请参考以下文章