using System.Text.RegularExpressions; using UnityEngine; using TMPro; public class Checking : MonoBehaviour { public void check() { string T=this.gameObject.GetComponent().text.Replace("_",""); this.gameObject.GetComponent().text = T; if(this.name=="I6"){ if(T != T.ToUpper()) { this.gameObject.GetComponent().text = T.ToUpper(); } } } public void checkEnd() { if(this.name=="I6"){ string text = this.gameObject.GetComponent().text; if(text != text.ToUpper()) { this.gameObject.GetComponent().text = text.ToUpper(); } if(text.Length>=6){this.gameObject.GetComponent().text=text.Substring(0,3)+" "+ text.Substring(3,3);} } if(this.name=="I8"){ string phone = this.gameObject.GetComponent().text; if (phone != null) { Get.o2("Feild","I8").GetComponent().text=FormatPhoneNumber( phone); } } } static string FormatPhoneNumber( string phoneNumber ) { if ( string.IsNullOrEmpty(phoneNumber) ) return phoneNumber; print("phoneNumber==="+phoneNumber); Regex phoneParser = null; string format = ""; phoneNumber=string.Join(null,System.Text.RegularExpressions.Regex.Split(phoneNumber, "[^\\d]")); print("phoneNumber==="+phoneNumber.Length ); switch( phoneNumber.Length ) { case 5 : phoneParser = new Regex(@"(\d{3})(\d{2})"); format = "$1 $2"; break; case 6 : phoneParser = new Regex(@"(\d{2})(\d{2})(\d{2})"); format = "$1 $2 $3"; break; case 7 : phoneParser = new Regex(@"(\d{3})(\d{2})(\d{2})"); format = "$1 $2 $3"; break; case 8 : phoneParser = new Regex(@"(\d{4})(\d{2})(\d{2})"); format = "$1 $2 $3"; break; case 9 : phoneParser = new Regex(@"(\d{4})(\d{3})(\d{2})(\d{2})"); format = "$1 $2 $3 $4"; break; case 10 : phoneParser = new Regex(@"(\d{3})(\d{3})(\d{4})"); format = "("+"$1"+") " +"$2"+"-"+" $3"; break; case 11 : phoneParser = new Regex(@"(\d{1})(\d{3})(\d{3})(\d{4})"); format = "$1"+"("+ "$2"+")"+"$3"+"-"+" $4"; break; default: return phoneNumber; }//switch return phoneParser.Replace( phoneNumber, format ); }//FormatPhoneNumber }