RegExp板 - WEB批踢踢(PTT)http://webptt.com/rss.ashx?n=RegExp2020-02-20T11:31:36+08:00Re: [請問] regexp的replace?https://webptt.com/m.aspx?n=/bbs/RegExp/M.1744013185.A.622.html2025-04-07T16:06:25+08:002025-04-08T19:48:40+08:00vernc<pre>,[dark(black,white,red)]light[FL-clover,(name)]back[2007,2009] ,[dark(blackwhitered)]light[FL-clover,(name)]back[2007,2009] copy,[dark,black,white,red]light[FL-clover,(name)]back[2007,2009] copy,[darkblackwhitered]light[FL-clover,(name)]back[2007,2009] 目標:移除第一個 [ 和 ] 之間的所有, </pre>Re: [問題] 怎抓到全部的()https://webptt.com/m.aspx?n=/bbs/RegExp/M.1728619438.A.BB1.html2024-10-11T12:03:58+08:002025-03-02T14:12:23+08:00vernc<pre>http://www.antp.be/software/renamer email作者請他更新TRegExpr版本 經過一年時光(看記錄是2023.12)回信了 那位幫忙測一下、看"negative lookahead" and "Recursion"等這些有沒有問題 若想增加什麼功能也可以說一聲 </pre>[閒聊] 原來正規表示法可以用來找質數https://webptt.com/m.aspx?n=/bbs/RegExp/M.1664128166.A.3D7.html2022-09-26T01:49:26+08:002023-12-25T22:52:52+08:00art1<pre> http://vimcasts.org/episodes/vimgolf-prime-numbers/ 這原本是 vimgolf 的題目,但解法很有意思,因此作者特別介紹,也找出最初的出處 首先要把每個數改用符號表示,像是 1 就用一個 *,2 就用 **,3 就用 *** 這連結的解法是用 Tab,最早出處是用 1 最主要的部份 </pre>XML取值問題https://webptt.com/m.aspx?n=/bbs/RegExp/M.1662467259.A.D60.html2022-09-06T20:27:39+08:002022-09-07T19:17:50+08:00sicao<pre>想問一下 手邊有個xml 架構大概是這樣.. 想請問一下 該怎麼下才能取得<TOTA>裡length的值?? <TITA> <TT>(其他外層的tag) </pre>[問題] 文章換行與空白行抓取問題https://webptt.com/m.aspx?n=/bbs/RegExp/M.1647609672.A.F75.html2022-03-18T21:21:12+08:002022-06-27T21:24:42+08:00sky91302018<pre>Regex規則:「(.*)」 文章: 「Hello World」 「 test test </pre>[問題] 有沒有辦法用 Regex 檢查對話框?https://webptt.com/m.aspx?n=/bbs/RegExp/M.1637907561.A.458.html2021-11-26T14:19:21+08:002021-11-26T19:52:25+08:00flirmnave<pre>在文字小說中,通常以 「」 中間放入人物的對話, 而有些可能是作者忽略了,有上括號(「)但沒有下括號(」)來結束對話。 要找合法的 「」 可以用: 「\S*?」 可以看 regex101 的測試:https://regex101.com/r/ZwY1Ns/1 </pre>[問題] Atomic Group 的原理是什麼?https://webptt.com/m.aspx?n=/bbs/RegExp/M.1636951819.A.EB0.html2021-11-15T12:50:19+08:002021-11-15T19:44:13+08:00kikilalagirl<pre>Atomic Group 的原理是什麼? 實在搞不懂, 想請教各位大大, 希望能指導一下. 謝謝. 下載 MSYS2 來練習 Regular Expression, 使用 grep.exe https://www.msys2.org/ 範例1: </pre>[問題] 怎抓到全部的()https://webptt.com/m.aspx?n=/bbs/RegExp/M.1633781746.A.61C.html2021-10-09T20:15:46+08:002022-02-18T20:44:45+08:00vernc<pre>[macdoll(マコ(・c_・))]shutter chance!!(ラブライブ) [しろむじ(ん坊主)]まる限定。((G)えでぃしょん) [PASTEL WING(如月あいす)]アイスフレンド(嫁)03(ガール(仮)) \(.*?\) \([^\n\)]*?\) </pre>[問題] 取代引號中的特定字串 (更)https://webptt.com/m.aspx?n=/bbs/RegExp/M.1633481805.A.1FB.html2021-10-06T08:56:45+08:002021-10-23T09:12:11+08:00hunandy14<pre>/* 聽說註明使用的語言、環境 * 問題有可能較容易被解決... */ 環境是用 POWERSHELL 跑 文本是整份檔案,這邊擷取一部分作範例 </pre>[問題] 擷取特定區間中特定字https://webptt.com/m.aspx?n=/bbs/RegExp/M.1615561701.A.737.html2021-03-12T23:08:21+08:002021-03-13T21:16:52+08:00lazcat<pre>/* 聽說註明使用的語言、環境 * 問題有可能較容易被解決... */ 使用C#9.0 <p>apple is an apple</p> </pre>[問題] 網頁元素問題https://webptt.com/m.aspx?n=/bbs/RegExp/M.1606310775.A.217.html2020-11-25T21:26:15+08:002020-11-29T14:51:50+08:00sicao<pre>想請問一下 比如像這種網頁元素 <input type="radio" name="color" value="red" > 如果我要取得裡面有id有name的input元件 並將id與name裡面的值取出 </pre>[問題] 請問一題正則表達式https://webptt.com/m.aspx?n=/bbs/RegExp/M.1604823668.A.1FE.html2020-11-08T16:21:08+08:002020-11-12T18:14:47+08:00fmtshk<pre>https://i.imgur.com/zf3ZZez.jpg 大家好,請問這題的答案(紅筆寫的),要如何理解? 鉛筆是我原本的回答,主要是不太懂 那個jm次方。 謝謝各位 -- </pre>Re: [請問] regexp的replace?https://webptt.com/m.aspx?n=/bbs/RegExp/M.1604135640.A.506.html2020-10-31T17:14:00+08:002020-11-07T21:00:46+08:00vernc<pre>[FL-clover、door、(天満春華)]返せ、かわり、○○で。[2007年、2009年](東方) [FL-clover,door,(天満春華)]返せ、かわり、○○で。[2007年、2009年](東方) 如上例若限定只將第一個[]範圍的n個、取代成, n不固定 ^([^\n[]*?\[[^]]*?)、([^]]*\]) $1,$2 </pre>[請問] regexp的replace?https://webptt.com/m.aspx?n=/bbs/RegExp/M.1603950151.A.C72.html2020-10-29T13:42:31+08:002020-10-30T06:22:59+08:00vernc<pre>[FL-clover、door、(天満春華)]返せ、かわり、○○で。(東方) [FL-clover,door,(天満春華)]返せ、かわり、○○で。(東方) 如上例想把[]範圍內的n個、取代成, n不固定 ^([^\n[]*?\[[^]]*?)、([^]]*\]) $1,$2 </pre>[問題] Everything找出所有非\d{3}.\w{3,4}$https://webptt.com/m.aspx?n=/bbs/RegExp/M.1594402452.A.5ED.html2020-07-11T01:34:12+08:002020-07-16T14:04:24+08:00vernc<pre>\d{3}.\w{3,4}$ 想把不符合上面檔名的全抓出來,下面這些能pass E:\artnonn\【Electromagnetic Wave(POP)】Unlutin koakumapop\001.jpg E:\artnonn\【Electromagnetic Wave(POP)】Unlutin koakumapop\002.jpg E:\artnonn\【Electromagnetic Wave(POP)】Unlutin koakumapop\003.png </pre>[問題] 挑出千分位錯誤的數字https://webptt.com/m.aspx?n=/bbs/RegExp/M.1584099163.A.D9E.html2020-03-13T19:32:43+08:002020-04-18T06:10:08+08:00liquidbox<pre>使用語言:Python 3 使用環境:Windows 10 我想製作一個小工具,檢查公司所需的文章,其格式是否存在一致性 其中一個格式是,阿拉伯數字必須要加千分位, 例如:123,000元(正確)、123000元(錯誤) </pre>Re: [問題] sed , grep 匹配問題https://webptt.com/m.aspx?n=/bbs/RegExp/M.1582681988.A.0BC.html2020-02-26T09:53:08+08:002020-02-26T09:53:07+08:00ericshei<pre>非常感謝您的說明 GNU的實作不是標準的POSIX standard https://www.regular-expressions.info/posix.html 上文提到如下: Some implementations support \? and \+ as an alternative syntax to \{0,1\} and \{1,\}, but \? and \+ are not part of the POSIX standard. </pre>Re: [問題] sed , grep 匹配問題https://webptt.com/m.aspx?n=/bbs/RegExp/M.1582559019.A.A93.html2020-02-24T23:43:39+08:002020-02-26T09:54:05+08:00DarkKiller<pre>你的問題是 GNU 的實做問題,如下。 ※ 引述《ericshei (ericshei)》之銘言: : 請教,我不理解為什麼^..*,[1-9]*,\+在如下grep , sed的結果是match的? : $ echo '11162,1,2020-02-17 19:59:31:696,+000000000 00:01:39.097' | grep '^..*,[1-9]*,\+' : 11162,1,2020-02-17 19:59:31:696,+000000000 00:01:39.097 </pre>[問題] sed , grep 匹配問題https://webptt.com/m.aspx?n=/bbs/RegExp/M.1582264062.A.336.html2020-02-21T13:47:42+08:002020-02-26T09:57:02+08:00ericshei<pre>請教,我不理解為什麼^..*,[1-9]*,\+在如下grep , sed的結果是match的? $ echo '11162,1,2020-02-17 19:59:31:696,+000000000 00:01:39.097' | grep '^..*,[1-9]*,\+' 11162,1,2020-02-17 19:59:31:696,+000000000 00:01:39.097 $ echo '11162,1,2020-02-17 19:59:31:696,+000000000 00:01:39.097' | sed 's/^..*,[1-9]*,\+/REPLACED/g' REPLACED2020-02-17 19:59:31:696,+000000000 00:01:39.097 </pre>[問題] Python match問題 missing )https://webptt.com/m.aspx?n=/bbs/RegExp/M.1582169496.A.D8C.html2020-02-20T11:31:36+08:002020-02-21T12:46:07+08:00ctr1<pre>Python 3.7 =====程式碼===== import re pattern = re.compile(r"goDetail('") match = pattern.match("goDetail('2069','17-104-214-3(21112)')") </pre>