验证输入的邮箱、手机号格式是否正确
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
using UnityEngine; using System.Collections; using System.Text.RegularExpressions; namespace Utils { public class InputUtil { static Regex emailRegex = new Regex( @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$" ); static Regex phoneRegex = new Regex( @"^[0-9]*$" ); public static bool IsValidInput( string userid ) { return userid.Length > 3 && userid.Length < 13; } public static bool IsValidEmail(string email) { Match match = emailRegex.Match(email); return match.Success; } public static bool IsValidPhoneNumber( string phoneNr ) { Match match = phoneRegex.Match( phoneNr ); return match.Success; } public static bool IsValidPassword(string password) { return password.Length > 5 && password.Length < 13; } } } |
- 本文固定链接: http://www.u3d8.com/?p=1076
- 转载请注明: 网虫虫 在 u3d8.com 发表过