[C#] 判斷是不是GUID的方法
2010/12/23
因為公司使用GUID是已經濾掉 - 符號
所以大致上會長這樣…
753361cc22954110a7c99ab4825571cf
如何判斷這是不是GUID呢?!
public bool IsGuid(string parseStr) { return (parseStr.Trim().Length == 32) ? Regex.Match(parseStr.Insert(8, "-").Insert(13, "-").Insert(18, "-").Insert(23, "-"),@"^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$", RegexOptions.IgnoreCase).Success:false; }
簡單的說先把 - 先補回去然後在去用Regular Expression 去判斷…
筆記一下…
讚一下:
標籤:
C#
|
This entry was posted on 下午2:34
and is filed under
C#
.
You can follow any responses to this entry through
the RSS 2.0 feed.
You can leave a response,
or trackback from your own site.
訂閱:
張貼留言 (Atom)
0 意見:
張貼留言