notepad++技巧 用正規表達式來搜尋和取代
搜尋換行符號
- windows系統的格式 \r\n
- linux系統的格式 \r
搜尋"空白"
- 注意全形空白
與半形空白
的差別
- tab換行的空白
\t
- html的空白
 :
反白後,再按搜尋or取代
先反白再按下搜尋會發生什麼事? 會自動將反白內容填入到尋找內容的格子
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
規則運算式 正規表達式 regex 是什麼?
[]
裡面代表要搜尋的目標
- [a-z] 只找小寫
- [A-z] 找大寫+小寫
- [0-9] 只找數字 (提醒:可以變化成 1-5)
- [A-z0-9] 找同時包含大小寫與數字混合的字
{}
裡面的數字代表要搜尋的長度
- {2,4} 找符合條件而且長度是2個字~4個字
- 可以只輸入{3,3}或是{3},只找符合條件且長度為3個字
規則運算式搜尋實例
例如 [0-9]{10}
,可以只搜尋電話號碼的數字
例如 [0-9]{4}-[0-9]{3}-[0-9]{3}
,可以搜尋包含-的電話號碼的數字
規則運算式搜尋,萬用字元(任何字都找到)與無限長度
例如:【.*】
,可以找到所有被【】符號包起來的資料
例如下面這一段,使用 【.*】
,搜尋時會把這樣一整串視為搜尋到1組資料【姓名】【Email】,而不是分開2組
改成 【.*?】
就可以兩組分開
規則運算式搜尋與取代
- 搜尋模式選擇 規則運算式
- 用( )框變數
- 用$1 $2當取代的關鍵字
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →