Visual Studio 中的 find- replace 可以使用Regex:
舉例:
從:
#define DS_MIN_ERROR 0
#define DS_ERROR 0
#define DS_DOWNLOAD_ERROR 1
#define DS_DB_DOWNLOAD_ERROR 2
#define DS_FD_INIT_ERROR 3 // CFileDownload Init Error
#define DS_DB_INIT_ERROR 4 // CFileDownload::DBINFO Init Error
#define DS_MAX_ERROR 99
#define DS_DB_COMPLETE 100
#define DS_DOWNLOAD_COMPLETE 101
#define DS_FD_RAW 200 //CFileDownload 初始化狀態
#define DS_FD_WAITING 201 //FD_WAITING 等待開始下載
#define DS_FD_DOWNLOADING 202
#define DS_WRITE_FILE 300
#define DS_DB_WRITE_FILE 301
#define DS_RELOCATION 400
改變成:
DS_MIN_ERROR = 0 ;
DS_ERROR = 0 ;
DS_DOWNLOAD_ERROR = 1 ;
DS_DB_DOWNLOAD_ERROR = 2 ;
DS_FD_INIT_ERROR = 3 ; // CFileDownload Init Error
DS_DB_INIT_ERROR = 4 ; // CFileDownload::DBINFO Init Error
DS_MAX_ERROR = 99 ;
DS_DB_COMPLETE = 100 ;
DS_DOWNLOAD_COMPLETE = 101 ;
DS_FD_RAW = 200 ; //CFileDownload 初始化狀態
DS_FD_WAITING = 201 ; //FD_WAITING 等待開始下載
DS_FD_DOWNLOADING = 202 ;
DS_WRITE_FILE = 300 ;
DS_DB_WRITE_FILE = 301 ;
DS_RELOCATION = 400 ;
只需要在 replace 菜單中填寫:
Find what:
/#define {[:c_]+}:b+{:d+}
Replace with:
/1 = /2 ;
注意在Find Options 中選擇:
Use:
regular expression
微軟的VS中Regular Expression 的資料 :
http://msdn.microsoft.com/en-us/library/2k3te2cs(VS.80,ide).aspx
這個正則文法和我們熟悉的不太一樣,比如 {} , :c :d