MacFormatter.cs 944 B

1234567891011121314151617181920212223242526272829
  1. //************************************************************************
  2. // author: yuzhengyang
  3. // date: 2018.3.27 - 2018.6.3
  4. // desc: 工具描述
  5. // Copyright (c) yuzhengyang. All rights reserved.
  6. //************************************************************************
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Text.RegularExpressions;
  12. namespace Azylee.Core.NetUtils
  13. {
  14. public class MacFormatter
  15. {
  16. /// <summary>
  17. /// 验证MAC地址格式
  18. /// </summary>
  19. /// <param name="mac"></param>
  20. /// <returns></returns>
  21. public static bool CheckMac(string mac)
  22. {
  23. Regex r = new Regex("[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]");
  24. if (r.IsMatch(mac)) return true;
  25. return false;
  26. }
  27. }
  28. }