^[0-9]+(.[0-9]{2})?$
demo:
https://regex101.com/r/CizAEg/1
2017年1月14日 星期六
RegExp判斷密碼必須是6~7碼英數字(至少需要一個數字和一個英文字)
^(?=.*\d)(?=.*[a-zA-Z]).{6,7}$
Demo:
https://regex101.com/r/jza4od/1
使用 Regular Expression 驗證密碼複雜度
http://blog.miniasp.com/post/2008/05/09/Using-Regular-Expression-to-validate-password.aspx
參考保哥部落格寫法
https://regex101.com/r/Xobl5s/1
Demo:
https://regex101.com/r/jza4od/1
使用 Regular Expression 驗證密碼複雜度
http://blog.miniasp.com/post/2008/05/09/Using-Regular-Expression-to-validate-password.aspx
參考保哥部落格寫法
- 至少有一個數字 => (?=.*\d)
- 至少有一個大寫或小寫英文字母 =>(?=.*[a-zA-Z])
- 至少有一個特殊符號 =>(?=.*\W) =>不是數字、字母、底線[azAZ09_]
- 字串長度在 6 ~ 30 個字母之間 =>.{6,30}
^(?=.*\d)(?=.*[a-zA-Z])(?=.*\W).{6,30}$
demo:https://regex101.com/r/Xobl5s/1
RegExp判斷五碼數字(郵遞區號5碼)
^\d{5}$
demo:
https://regex101.com/r/o2TPJ0/1
NNN|NNNNN
^[0-9]{3,3}|[0-9]{5,5}$
https://msdn.microsoft.com/zh-tw/library/partnercenter/dn974938.aspx
demo:
https://regex101.com/r/o2TPJ0/1
NNN|NNNNN
^[0-9]{3,3}|[0-9]{5,5}$
https://msdn.microsoft.com/zh-tw/library/partnercenter/dn974938.aspx
2017年1月2日 星期一
利用FileHelpers檢查csv格式
在Visual Studio的套件管理器主控台輸入Install-Package FileHelpers
可以下載編譯好的DLL: FileHelpers_3.1.5_Build.zip (目前最新版本)
原始碼可以到該專案的Github下載
需要建立一個對映的Record Mapping Class
如果csv檔不符合對映就會出FileHelpers.BadUsageException
另一種處理CSV工具:CsvHelper
使用 CsvHelper - Part.2 資料讀取
http://kevintsengtw.blogspot.tw/2015/04/csvhelper-part2.html
REF:
How to validate a .csv file before storage in C#?
http://stackoverflow.com/questions/16608486/how-to-validate-a-csv-file-before-storage-in-c
How to validate CSV in C#?
http://stackoverflow.com/questions/24765492/how-to-validate-csv-in-c
C#判斷使用者輸入的本機路徑路徑是有效的
在stackoverflow看到的一片文章:Check if a string is a valid Windows directory (folder) path
可以使用Path.GetFullPath去判斷使用者輸入的本機路徑路徑是有效的
如果是無效的會丟出System.ArgumentException
只是空白字元算有效字元,如果怕使用者誤多輸入空白,可以自己判斷
if (inputPath.Contains(" ") )
Naming Files, Paths, and Namespaces
https://msdn.microsoft.com/en-us/library/aa365247
What characters are forbidden in Windows and Linux directory names?
http://stackoverflow.com/questions/1976007/what-characters-are-forbidden-in-windows-and-linux-directory-names
可以使用Path.GetFullPath去判斷使用者輸入的本機路徑路徑是有效的
如果是無效的會丟出System.ArgumentException
只是空白字元算有效字元,如果怕使用者誤多輸入空白,可以自己判斷
if (inputPath.Contains(" ") )
Naming Files, Paths, and Namespaces
https://msdn.microsoft.com/en-us/library/aa365247
Use any character in the current code page for a name, including Unicode characters and characters in the extended character set (128–255), except for the following:
- The following reserved characters:
- < (less than)
- > (greater than)
- : (colon)
- " (double quote)
- / (forward slash)
- \ (backslash)
- | (vertical bar or pipe)
- ? (question mark)
- * (asterisk)
- Integer value zero, sometimes referred to as the ASCII NUL character.
- Characters whose integer representations are in the range from 1 through 31, except for alternate data streams where these characters are allowed. For more information about file streams, see File Streams.
- Any other character that the target file system does not allow.
What characters are forbidden in Windows and Linux directory names?
http://stackoverflow.com/questions/1976007/what-characters-are-forbidden-in-windows-and-linux-directory-names
訂閱:
文章 (Atom)