正则表达式实现中文的大写字符

前端之家收集整理的这篇文章主要介绍了正则表达式实现中文的大写字符前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
package ch17_1
{
	import flash.display.MovieClip;
	
	public class Text6 extends MovieClip
	{
		public function Text6()
		{
			var myP:RegExp =/([一二三四五六七八九十百千万])/g;
			var myString:String ="六万五千三百二十八";
			var output:String = myString.replace(myP,replaceFunction);
			function replaceFunction():String
			{
				//arguments[1]是指正则表达式中被小括号组括起来的第一个匹配项
				switch(arguments[1])
				{
					case "一":
						return "壹";
						break;
					case "二":
						return "贰";
						break;
					case "三":
						return "叁";
						break;
					case "四":
						return "肆";
						break;
					case "五":
						return "伍";
						break;
					case "六":
						return "陆";
						break;
					case "七":
						return "柒";
						break;
					case "八":
						return "捌";
						break;
					case "九":
						return "玖";
						break;
					case "十":
						return "拾";
						break;
					case "百":
						return "佰";
						break;
					case "千":
						return "仟";
						break;
					case "万":
						return "萬";
						break;
					default :
						return "";
				}
			}
			
			
			trace(output);
		}
	}
}
原文链接:https://www.f2er.com/regex/362637.html

猜你在找的正则表达式相关文章