13,477
edits
Tags: Mobile edit Mobile web edit |
|||
(37 intermediate revisions by the same user not shown) | |||
Line 43: | Line 43: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> 任意次的 ASCII character(包含英文、數字和空白) [http://regexr.com/3aom2 demo]<ref>[http://www.asciitable.com/ Ascii Table - ASCII character codes and html, octal, hex and decimal chart conversion]</ref> <br /> {{kbd | key = <nowiki>[\x00-\x80]+</nowiki>}} 或 {{kbd | key = <nowiki>[[:ascii:]]+</nowiki>}}<ref>[https://stackoverflow.com/questions/24903140/regex-for-any-english-ascii-character-including-special-characters php - Regex for Any English ASCII Character Including Special Characters - Stack Overflow]</ref></td> | <td> 任意次的 ASCII character (包含英文、數字和空白) [http://regexr.com/3aom2 demo]<ref>[http://www.asciitable.com/ Ascii Table - ASCII character codes and html, octal, hex and decimal chart conversion]</ref> <br /> {{kbd | key = <nowiki>[\x00-\x80]+</nowiki>}} 或 {{kbd | key = <nowiki>[[:ascii:]]+</nowiki>}}<ref>[https://stackoverflow.com/questions/24903140/regex-for-any-english-ascii-character-including-special-characters php - Regex for Any English ASCII Character Including Special Characters - Stack Overflow]</ref></td> | ||
<td><span style="background:#C6E3FF">What Does the Fox Say? 12</span> 狐狸怎叫 34</td> | <td><span style="background:#C6E3FF">What Does the Fox Say? 12</span> 狐狸怎叫 34</td> | ||
<td>非 ASCII,即中文出現任意次<br /> {{kbd | key = <nowiki>[^\x00-\x80]+</nowiki>}}</td> | <td>非 ASCII,即中文出現任意次<br /> {{kbd | key = <nowiki>[^\x00-\x80]+</nowiki>}}</td> | ||
Line 49: | Line 49: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> 任意次的大小寫英文、數字和底線符號( _ ) | <td> 任意次的大小寫英文、數字和底線符號( _ ) (不包含空白) ([https://regex101.com/r/gIKB6a/1 demo])<br /> {{kbd | key = <nowiki>[\w]+</nowiki>}} = {{kbd | key = <nowiki>[a-zA-Z0-9_]+</nowiki>}} <br /> PHP 加上 {{kbd | key =u}} 修飾語,則可支援中文字 </td> | ||
<td><span style="background:#C6E3FF">What</span> Does the Fox Say? 12 狐狸怎叫 | <td><span style="background:#C6E3FF">What</span> <span style="background:#C6E3FF">Does</span> <span style="background:#C6E3FF">the</span> <span style="background:#C6E3FF">Fox</span> <span style="background:#C6E3FF">Say</span>? <span style="background:#C6E3FF">12</span> 狐狸怎叫 <span style="background:#C6E3FF">_34</span></td> | ||
<td> 任意次的不是英文、數字和底線符號( _ )的文字 <br /> {{kbd | key = <nowiki>\W+</nowiki>}} = {{kbd | key = <nowiki>[^a-zA-Z0-9_]+</nowiki>}}</td> | <td> 任意次的不是英文、數字和底線符號( _ )的文字 <br /> {{kbd | key = <nowiki>\W+</nowiki>}} = {{kbd | key = <nowiki>[^a-zA-Z0-9_]+</nowiki>}}</td> | ||
<td>[http://regexr.com/3bk4v demo]</td> | <td>[http://regexr.com/3bk4v demo]</td> | ||
Line 91: | Line 91: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> 包含「狐狸」的行 <br /> {{kbd | key = <nowiki>^.*狐狸.*$</nowiki>}}</td> | <td> 包含「狐狸」的行 <br /> {{kbd | key = <nowiki>^.*狐狸.*$</nowiki>}} 或 {{kbd | key = <nowiki>(狐狸)</nowiki>}} ([https://regex101.com/r/UEtYst/1 demo])</td> | ||
<td> | <td> | ||
<span style="background:#C6E3FF">What Does the Fox Say? 12 狐狸怎叫 34</span><br /> | <span style="background:#C6E3FF">What Does the Fox Say? 12 狐狸怎叫 34</span><br /> | ||
What Does the shiba inu say? 柴犬怎叫 | What Does the shiba inu say? 柴犬怎叫 | ||
</td> | </td> | ||
<td>不包含「狐狸」的行 | <td>不包含「狐狸」的行 ([https://regex101.com/r/rvncjU/1 demo]) <br /> {{kbd | key = <nowiki>^((?!狐狸).)*$</nowiki>}} </td> | ||
<td> | <td> | ||
What Does the Fox Say? 12 狐狸怎叫 34<br /> | What Does the Fox Say? 12 狐狸怎叫 34<br /> | ||
Line 103: | Line 103: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> 布林邏輯 AND: 包含「狐狸」和「叫」的行 ([http://regexr.com/3aokl demo])<ref>[http://stackoverflow.com/questions/469913/regular-expressions-is-there-an-and-operator regex - Regular Expressions: Is there an AND operator? - Stack Overflow]</ref><br /> {{kbd | key = <nowiki>(?=.*狐狸)(?=.*叫).*</nowiki>}}</td> | <td> 布林邏輯 AND: 包含「狐狸」和「叫」的行 ([http://regexr.com/3aokl demo])<ref>[http://stackoverflow.com/questions/469913/regular-expressions-is-there-an-and-operator regex - Regular Expressions: Is there an AND operator? - Stack Overflow]</ref><br /> {{kbd | key = <nowiki>(?=.*狐狸)(?=.*叫).*</nowiki>}} 或 {{kbd | key = <nowiki>狐狸.*叫|叫.*狐狸</nowiki>}}</td> | ||
<td> | <td> | ||
<span style="background:#C6E3FF">What Does the Fox Say? 12 狐狸怎叫 34</span><br /> | <span style="background:#C6E3FF">What Does the Fox Say? 12 狐狸怎叫 34</span><br /> | ||
Line 113: | Line 113: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> 布林邏輯 OR: 包含「狐狸」或「叫」的行 ([ | <td> 布林邏輯 OR: 包含「狐狸」或「叫」的行 ([https://regexr.com/6cu06 demo])<br /> {{kbd | key = <nowiki>.*(狐狸|叫).*</nowiki>}}</td> | ||
<td> | <td> | ||
<span style="background:#C6E3FF">What Does the Fox Say? 12 狐狸怎叫 34<br /> | <span style="background:#C6E3FF">What Does the Fox Say? 12 狐狸怎叫 34<br /> | ||
Line 125: | Line 125: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td> 布林邏輯 NOT: 不包含「狐狸」,但包含「柴犬」的行 ([http://regexr.com/3aokr demo])<ref>[http://stackoverflow.com/questions/2953039/regular-expression-for-a-string-containing-one-word-but-not-another regex - Regular expression for a string containing one word but not another - Stack Overflow]</ref><br /> {{kbd | key = <nowiki>^((?!狐狸).)*(柴犬).*$</nowiki>}} = {{kbd | key = <nowiki>^(柴犬).*((?!狐狸).)*$</nowiki>}} = {{kbd | key = <nowiki>(柴犬).*((?!狐狸).)*</nowiki>}}</td> | <td> 布林邏輯 NOT: 不包含「狐狸」,但包含「柴犬」的行 ([http://regexr.com/3aokr demo])<ref>[http://stackoverflow.com/questions/2953039/regular-expression-for-a-string-containing-one-word-but-not-another regex - Regular expression for a string containing one word but not another - Stack Overflow]</ref><br /> {{kbd | key = <nowiki>^((?!狐狸).)*(柴犬).*$</nowiki>}} = {{kbd | key = <nowiki>^(柴犬).*((?!狐狸).)*$</nowiki>}} = {{kbd | key = <nowiki>(柴犬).*((?!狐狸).)*</nowiki>}} (如果句子同時存在狐狸和柴犬會出錯) </td> | ||
<td> | <td> | ||
What Does the Fox Say? 12 狐狸怎叫 34<br /> | What Does the Fox Say? 12 狐狸怎叫 34<br /> | ||
Line 143: | Line 143: | ||
* [http://www.rubular.com/ Rubular]: a Ruby regular expression editor and tester ([http://www.rubular.com/r/UZuUT5pjeh example]) | * [http://www.rubular.com/ Rubular]: a Ruby regular expression editor and tester ([http://www.rubular.com/r/UZuUT5pjeh example]) | ||
* [http://www.phpliveregex.com/ PHP Live Regex] {{access | date=2014-11-25}} | * [http://www.phpliveregex.com/ PHP Live Regex] {{access | date=2014-11-25}} | ||
* [http://www.regextester.com/ Regex Tester and Debugger Online - Javascript, PCRE, PHP] {{access | date=2016-01-07}} | * [http://www.regextester.com/ Regex Tester and Debugger Online - Javascript, PCRE, PHP] {{access | date=2016-01-07}} | ||
* [http://rocksaying.tw/archives/2670695.html Regular Expression (RegExp) in JavaScript - 石頭閒語] {{access | date=2017-11-14}} | * [http://rocksaying.tw/archives/2670695.html Regular Expression (RegExp) in JavaScript - 石頭閒語] {{access | date=2017-11-14}} | ||
Examples | |||
* {{Gd}} [http://regexlib.com/ Regular Expression Library] 網友提供的 pattern 範例 | * {{Gd}} [http://regexlib.com/ Regular Expression Library] 網友提供的 pattern 範例 | ||
Line 337: | Line 336: | ||
* Find what: {{kbd | key = <nowiki>(.*)$\n</nowiki>}} 或 {{kbd | key = <nowiki>(\S+)$\n</nowiki>}} 或 {{kbd | key = <nowiki>(\S+)\n</nowiki>}} | * Find what: {{kbd | key = <nowiki>(.*)$\n</nowiki>}} 或 {{kbd | key = <nowiki>(\S+)$\n</nowiki>}} 或 {{kbd | key = <nowiki>(\S+)\n</nowiki>}} | ||
* Replace with: {{kbd | key = <nowiki>'\1', </nowiki>}} | * Replace with: {{kbd | key = <nowiki>'\1', </nowiki>}} | ||
More details on the page [[Add quotation at the start and end of each line | add quotation at the start and end of each line]]. | |||
</div> | </div> | ||
Line 366: | Line 367: | ||
* [https://errerrors.blogspot.com/2019/03/how-to-enclose-non-empty-cell-with-double-quotes-in-google-spreadsheet.html Google 試算表的文字類型欄位值的前後加上雙引號] | * [https://errerrors.blogspot.com/2019/03/how-to-enclose-non-empty-cell-with-double-quotes-in-google-spreadsheet.html Google 試算表的文字類型欄位值的前後加上雙引號] | ||
=== 尋找中文、非英文的文字 === | === Find non-ASCII characters 尋找中文、非英文的文字 === | ||
==== Find non-ASCII characters in Google sheet ==== | |||
適用: Google Drive 試算表的 Regular expression 相關函數,例如: [https://support.google.com/docs/answer/3098292?hl=zh-Hant REGEXMATCH]、[https://support.google.com/docs/answer/3098244?hl=en REGEXEXTRACT]、[https://support.google.com/docs/answer/3098245?hl=zh-Hant RegExReplace] 函數、Notepad++的搜尋 | 適用: Google Drive 試算表的 Regular expression 相關函數,例如: [https://support.google.com/docs/answer/3098292?hl=zh-Hant REGEXMATCH]、[https://support.google.com/docs/answer/3098244?hl=en REGEXEXTRACT]、[https://support.google.com/docs/answer/3098245?hl=zh-Hant RegExReplace] 函數、Notepad++的搜尋 | ||
<pre> | <pre> | ||
Line 372: | Line 374: | ||
</pre> | </pre> | ||
==== Find non-ASCII characters in LibreOffice ==== | |||
適用: [https://zh-tw.libreoffice.org/ LibreOffice] [https://help.libreoffice.org/6.2/en-US/text/scalc/01/func_regex.html REGEX] function<ref>[https://help.libreoffice.org/6.2/en-US/text/shared/01/02100001.html?&DbPAR=WRITER&System=MAC List of Regular Expressions]</ref>、Total commander 的 Multi-Rename tool<ref>取代非英文的文字,但是不包含 . 符號: <nowiki>[^\u0000-\u0080|.]+ </nowiki></ref><ref>[http://stackoverflow.com/questions/150033/regular-expression-to-match-non-english-characters javascript - Regular expression to match non-english characters? - Stack Overflow]</ref> | 適用: [https://zh-tw.libreoffice.org/ LibreOffice] [https://help.libreoffice.org/6.2/en-US/text/scalc/01/func_regex.html REGEX] function<ref>[https://help.libreoffice.org/6.2/en-US/text/shared/01/02100001.html?&DbPAR=WRITER&System=MAC List of Regular Expressions]</ref>、Total commander 的 Multi-Rename tool<ref>取代非英文的文字,但是不包含 . 符號: <nowiki>[^\u0000-\u0080|.]+ </nowiki></ref><ref>[http://stackoverflow.com/questions/150033/regular-expression-to-match-non-english-characters javascript - Regular expression to match non-english characters? - Stack Overflow]</ref> | ||
<pre> | <pre> | ||
Line 377: | Line 380: | ||
</pre> | </pre> | ||
==== Find Chinese characters in Google sheet ==== | |||
範例:如果 A2 包含任一中文字,則欄位值顯示「中文」。如果未包含任何中文字,則欄位值顯示「英文」: | |||
<pre> | |||
=IF(REGEXMATCH(A2, "[\一-\龥]"), "中文", "英文") | |||
</pre> | |||
{{exclaim}} Google 不支援以下語法,會顯示「... 是無效的規則運算式。」錯誤 | |||
* {{kbd | key=<nowiki>[\u4e00-\u9fa5]</nowiki>}} | |||
* {{kbd | key=<nowiki>[^\u4e00-\u9fa5]</nowiki>}} | |||
* {{kbd | key=<nowiki>[\p{Script=Hans}]</nowiki>}} | |||
* {{kbd | key=<nowiki>[\p{Han}]</nowiki>}} | |||
==== Find Chinese characters in MySQL ==== | |||
尋找 `column_name` 欄位值包含中文字。適用: MySQL<ref>[https://stackoverflow.com/questions/9795137/how-to-detect-rows-with-chinese-characters-in-mysql How to detect rows with chinese characters in MySQL? - Stack Overflow]</ref><ref>[https://stackoverflow.com/questions/401771/how-can-i-find-non-ascii-characters-in-mysql How can I find non-ASCII characters in MySQL? - Stack Overflow]</ref> | |||
<pre> | <pre> | ||
SELECT `column_name` | SELECT `column_name` | ||
FROM `table_name` | FROM `table_name` | ||
Line 385: | Line 400: | ||
</pre> | </pre> | ||
說明 | |||
* 正則表達式 '^(..)*(E[4-9])' 的含義是尋找從字符串開始處(表示為 ^),每兩個字符(表示為 ..)重複零次或多次(表示為 *),直到找到一個匹配 (E[4-9]) 的序列。 | |||
* 透過加入 ^(..)* 使得搜尋條件更加嚴格,它要求 (E[4-9]) 的出現位置必須是在一個合法的 UTF-8 字符邊界上。這意味著它更可能正確匹配開頭為中文字符的字符串,而忽略那些僅在中間或末尾偶然包含 E4 到 E9 序列的非中文字符串。 | |||
==== Find non-ASCII characters in MySQL ==== | |||
尋找 `column_name` 欄位值不完全是 ASCII 字元 | |||
<pre> | |||
SELECT `column_name` | |||
FROM `table_name` | |||
WHERE `column_name` <> CONVERT(`column_name` USING ASCII) | |||
</pre> | |||
==== Find non-ASCII characters in PHP ==== | |||
尋找欄位值包含中文字,中文字包含繁體中文與簡體中文,不包含標點符號 (例如 {{kbd | key = <nowiki>,</nowiki>}})、全形標點符號 (例如 {{kbd | key = <nowiki>,</nowiki>}})以及特殊符號,例如 Emoji:{{kbd | key = ⭐}}。 | 尋找欄位值包含中文字,中文字包含繁體中文與簡體中文,不包含標點符號 (例如 {{kbd | key = <nowiki>,</nowiki>}})、全形標點符號 (例如 {{kbd | key = <nowiki>,</nowiki>}})以及特殊符號,例如 Emoji:{{kbd | key = ⭐}}。 | ||
PHP: exact match | PHP: exact match | ||
Line 424: | Line 452: | ||
解決方式: [http://php.net/manual/en/function.preg-match.php preg_match()] 需要加上 {{kbd | key = u }} 變數<ref>[https://stackoverflow.com/questions/32375531/preg-match-compilation-failed-character-value-in-x-or-o-is-too-large-a php - preg_match(): Compilation failed: character value in \x{} or \o{} is too large at offset 27 on line number 25 - Stack Overflow]</ref>。 | 解決方式: [http://php.net/manual/en/function.preg-match.php preg_match()] 需要加上 {{kbd | key = u }} 變數<ref>[https://stackoverflow.com/questions/32375531/preg-match-compilation-failed-character-value-in-x-or-o-is-too-large-a php - preg_match(): Compilation failed: character value in \x{} or \o{} is too large at offset 27 on line number 25 - Stack Overflow]</ref>。 | ||
==== Find non-ASCII characters in JavaScript ==== | |||
* [https://stackoverflow.com/questions/21109011/javascript-unicode-string-chinese-character-but-no-punctuation regex - Javascript unicode string, chinese character but no punctuation - Stack Overflow] | |||
參考資料: | 參考資料: | ||
* [http://blog.csdn.net/tinyletero/article/details/8201465 unicode编码 \u4e00-\u9fa5 匹配所有中文 - CSDN博客] | * [http://blog.csdn.net/tinyletero/article/details/8201465 unicode编码 \u4e00-\u9fa5 匹配所有中文 - CSDN博客] | ||
* [https://stackoverflow.com/questions/38168419/codeigniter-form-validation-for-chinese-words php - CodeIgniter Form Validation for Chinese Words - Stack Overflow] | * [https://stackoverflow.com/questions/38168419/codeigniter-form-validation-for-chinese-words php - CodeIgniter Form Validation for Chinese Words - Stack Overflow] | ||
* [https://zh.wikipedia.org/zh-tw/%E4%B8%AD%E6%97%A5%E9%9F%93%E7%B5%B1%E4%B8%80%E8%A1%A8%E6%84%8F%E6%96%87%E5%AD%97%E5%88%97%E8%A1%A8 中日韓統一表意文字列表 - 維基百科,自由的百科全書] | |||
=== 尋找英文字 === | |||
==== 尋找 ASCII 字元 in MySQL ==== | |||
<pre> | |||
-- 尋找欄位 `my_column` 欄位值是 ASCII 字元 | |||
SELECT * | |||
FROM `my_table` | |||
WHERE `my_column` LIKE CONVERT(`my_column` USING ASCII) | |||
</pre> | |||
相關文章 | |||
* [https://errerrors.blogspot.com/2020/07/search-app-not-apple-in-englishsearching.html 解決英文字的搜尋:搜尋 app 而不是 apple] | |||
參考資料 | |||
* [https://stackoverflow.com/questions/401771/how-can-i-find-non-ascii-characters-in-mysql How can I find non-ASCII characters in MySQL? - Stack Overflow] | |||
==== 尋找英文字、數字、破折號(-)或底線(_)字元 in MySQL ==== | |||
<pre> | |||
-- 尋找欄位 `my_column` 欄位值是包含英文字、數字、破折號(-)或底線(_)的字串 | |||
SELECT * | |||
FROM `my_table` | |||
WHERE `my_column` REGEXP '[a-zA-Z0-9\-_]' | |||
</pre> | |||
=== 將每行文字的行頭加上逗號符號 === | === 將每行文字的行頭加上逗號符號 === | ||
[[Adding characters to document lines]] | |||
=== 知道前面跟後面的文字,但是中間文字忘記了 === | === 知道前面跟後面的文字,但是中間文字忘記了 === | ||
Line 468: | Line 521: | ||
* 使用工具: 適用 Sublime Text 與 EmEditor 軟體,需勾選「使用規則運算式」。{{exclaim}} 以下語法不適用於 Notepad++ 軟體<ref>[http://www.sitepoint.com/forums/showthread.php?448843-Regex-delete-multiple-blank-lines Regex: delete multiple blank lines]</ref> | * 使用工具: 適用 Sublime Text 與 EmEditor 軟體,需勾選「使用規則運算式」。{{exclaim}} 以下語法不適用於 Notepad++ 軟體<ref>[http://www.sitepoint.com/forums/showthread.php?448843-Regex-delete-multiple-blank-lines Regex: delete multiple blank lines]</ref> | ||
** 尋找: {{kbd | key=<nowiki>^[\s\t]*$\n</nowiki>}} --> 取代為: 空 (不需要輸入任何字) | ** 尋找: {{kbd | key=<nowiki>^[\s\t]*$\n</nowiki>}} --> 取代為: 空 (不需要輸入任何字) | ||
* 使用工具: Notepad++ | * 使用工具: Notepad++ v7.8.7 | ||
** Notepad++ 軟體選單: 編輯 -> | ** Notepad++ 軟體選單: 編輯 -> 行處理 -> 移除空行(包括只有空白字元的行)<ref>[http://stackoverflow.com/questions/3866034/removing-empty-lines-in-notepad regex - Removing empty lines in Notepad++ - Stack Overflow]</ref> | ||
* 詳細說明,請見 [[Regular replace blank lines]] | * 詳細說明,請見 [[Regular replace blank lines]] | ||
=== 尋找非空白的文字 === | === 尋找非空白的文字 === | ||
* 尋找: {{kbd | key=<nowiki>[^\s]+</nowiki>}} [https://regex101.com/r/zH7wV3/1 online demo] | * 尋找: {{kbd | key=<nowiki>[^\s]+</nowiki>}} [https://regex101.com/r/zH7wV3/1 online demo] | ||
* [https://errerrors.blogspot.com/2022/01/avoid-whitespace-character-caused-program-stop-abnormally.html 解決遇到空白段落發生程式異常錯誤而執行中斷的問題] 「... 看起來空白的字元,卻無法使用 TRIM 函數去除,可能是其他的空白字元。解決方式是偵測段落內有沒有包含中英文、數字,再進行後續處理。」 | |||
=== 去除標點符號、特殊符號等 === | |||
* [https://stackoverflow.com/questions/5689918/php-strip-punctuation/5689989 regex - PHP strip punctuation - Stack Overflow] | |||
=== 將特定符號相隔的文字,改成逐行顯示 === | === 將特定符號相隔的文字,改成逐行顯示 === | ||
Line 500: | Line 558: | ||
* <nowiki>[、]{1}</nowiki> : 出現頓號(、)一次的文字 | * <nowiki>[、]{1}</nowiki> : 出現頓號(、)一次的文字 | ||
* <nowiki>([、]{1})</nowiki> : 符合「出現頓號(、)一次的文字」規則的文字 | * <nowiki>([、]{1})</nowiki> : 符合「出現頓號(、)一次的文字」規則的文字 | ||
=== 將每行文字的結尾處,加入空一格 (半形空白) === | === 將每行文字的結尾處,加入空一格 (半形空白) === | ||
Line 573: | Line 630: | ||
=== 尋找文章內容中的網址 === | === 尋找文章內容中的網址 === | ||
[[ | [[Extract url from text]] | ||
=== 尋找數字 === | === 尋找數字 === | ||
Line 580: | Line 638: | ||
* [[Extract large number from text | 尋找文章內容中的長數字]] | * [[Extract large number from text | 尋找文章內容中的長數字]] | ||
* [https://errerrors.blogspot.com/2020/02/convert-minguo-calendar-to-common-era-using-google-sheet.html Google 試算表將民國轉西元日期] | * [https://errerrors.blogspot.com/2020/02/convert-minguo-calendar-to-common-era-using-google-sheet.html Google 試算表將民國轉西元日期] | ||
=== 移除刮號內的文字 === | |||
請參考 [[Remove text within brackets]] | |||
=== Search unmatched string === | === Search unmatched string === | ||
Line 596: | Line 657: | ||
[^/](console\.log) | [^/](console\.log) | ||
</pre> | </pre> | ||
== Text editor with support for regular expression == | |||
[[Text editor with support for regular expression]] | |||
== Regular expression batch tools == | == Regular expression batch tools == | ||
Line 613: | Line 677: | ||
== Troubleshooting of regular expression == | == Troubleshooting of regular expression == | ||
Tips | Tips | ||
* Use online tool [https://regex101.com/ regex101: build, test, and debug regex] to obtain the explain of your syntax | |||
* Small data test: (1) Prepare the small file data to verify the syntax (2) Using the [[Regular_expression#Regular_expression_online_tools | online tools]] | * Small data test: (1) Prepare the small file data to verify the syntax (2) Using the [[Regular_expression#Regular_expression_online_tools | online tools]] | ||
* Highlight or output the matched text e.g. {{kbd | key=<nowiki>--color</nowiki>}}<ref>[https://www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/grep_command_examples/ Grep -color command Examples - nixCraft]</ref> for grep command or output the matches by PHP [http://php.net/manual/en/function.preg-match.php preg_match()] function. | * Highlight or output the matched text e.g. {{kbd | key=<nowiki>--color</nowiki>}}<ref>[https://www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/grep_command_examples/ Grep -color command Examples - nixCraft]</ref> for grep command or output the matches by PHP [http://php.net/manual/en/function.preg-match.php preg_match()] function. | ||
Line 647: | Line 712: | ||
{{Template:Troubleshooting}} | {{Template:Troubleshooting}} | ||
[[Category:Regular expression]] [[Category:Software]] [[Category:Programming]] [[Category:Data Science]] [[Category:Search]] [[Category: | [[Category:Regular expression]] [[Category:Software]] [[Category:Programming]] [[Category:Data Science]] [[Category:Search]] [[Category:String manipulation]] |