




免費預覽已結束,剩余1頁可下載查看
下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
TRegExOption = ( roNone, /無 roIgnoreCase, /不區(qū)分大小寫 roMultiLine, /多行模式; 可使 和 $ 匹配每個行首或行尾 roExplicitCapture, /只捕獲指定了名稱或編號的子表達式 roCompiled, /預編譯表達式; 這在反復使用更有效率 roSingleLine, /單行模式; 使 . 也可匹配換行符 roIgnorePatternSpace /忽略注釋和未經轉義的空白);uses RegularExpressions;roIgnoreCaseprocedure TForm1.Button1Click(Sender: TObject);const pattern = A-Z+d+; txt = AAA1 bbb2 aa11 bb22 A111 B222 AAAA;var match: TMatch;begin Memo1.Clear; for match in TRegEx.Matches(txt, pattern, roIgnoreCase) do begin Memo1.Lines.Add(match.Value); end; Memo1.Lines.Add(-); for match in TRegEx.Matches(txt, pattern) do begin Memo1.Lines.Add(match.Value); end;end;*AAA1bbb2aa11bb22A111B222-AAA1A111B222*roMultiLineprocedure TForm1.Button2Click(Sender: TObject);const txt = Delphi Delphi Delphi#13#10Delphi Delphi Delphi;var rStr: string;begin Memo1.Clear; 行首 rStr := TRegEx.Replace(txt, Delphi, ., roMultiLine); Memo1.Lines.Add(rStr); Memo1.Lines.Add(-); rStr := TRegEx.Replace(txt, Delphi, .); Memo1.Lines.Add(rStr); Memo1.Lines.Add(-); 行尾 rStr := TRegEx.Replace(txt, Delphi$, ., roMultiLine); Memo1.Lines.Add(rStr); Memo1.Lines.Add(-); rStr := TRegEx.Replace(txt, Delphi$, .); Memo1.Lines.Add(rStr);end;*. Delphi Delphi. Delphi Delphi-. Delphi DelphiDelphi Delphi Delphi-Delphi Delphi .Delphi Delphi .-Delphi Delphi DelphiDelphi Delphi .*roExplicitCaptureprocedure TForm1.Button3Click(Sender: TObject);const pattern1 = (A-Z+)(d+); pattern2 = (?A-Z+)(d+); pattern3 = (A-Z+)(?d+); txt = AA11 BB22;var match: TMatch; group: TGroup;begin Memo1.Clear; for match in TRegEx.Matches(txt, pattern1, roExplicitCapture) do begin for group in match.Groups do begin Memo1.Lines.Add(group.Value); end; end; Memo1.Lines.Add(-); for match in TRegEx.Matches(txt, pattern1) do /此處把 pattern1 換做 pattern2 或 pattern3 均可 begin for group in match.Groups do begin Memo1.Lines.Add(group.Value); end; end; Memo1.Lines.Add(-); for match in TRegEx.Matches(txt, pattern2, roExplicitCapture) do begin for group in match.Groups do begin Memo1.Lines.Add(group.Value); end; end; Memo1.Lines.Add(-); for match in TRegEx.Matches(txt, pattern3, roExplicitCapture) do begin for group in match.Groups do begin Memo1.Lines.Add(group.Value); end; end;end;*AA11BB22-AA11AA11BB22BB22-AA11AABB22BB-AA1111BB2222*roCompiledprocedure TForm1.Button4Click(Sender: TObject);var reg: TRegEx;begin reg := TRegEx.Create(d+, roCompiled); Memo1.Text := reg.Replace(AA11 BB22, .); /AA. BB.end;roSingleLineprocedure TForm1.Button5Click(Sender: TObject);const pattern = A-Z1.1; txt = A B C D#13#10A B C D#13#10A B C D;var rStr: string;begin Memo1.Clear; rStr := TRegEx.Replace(txt, pattern, 11, roSingleLine); Memo1.Lines.Add(rStr); Memo1.Lines.Add(-); rStr := TRegEx.Replace(txt, pattern, 11); Memo1.Lines.Add(rStr);end;*1111111111111111111111D-111111D111111D111111D*roIgnorePatternSpaceprocedure TForm1.Button6Click(Sender: TObject);var rStr: string;begin Memo1.Clear; 忽略空白 rStr := TRegEx.Replace(ABC,A B C,AB C, AB C, ., roIgnorePatternSpace); Memo1.Lines.Add(rStr); /.,A B C,AB C rStr := TRegEx.Replace(ABC,A B C,AB C, AB C, .); Memo1.Lines.Add(rStr); /ABC,A B C,. Memo1.Lines.Add(-); 使用注釋 rStr := TRegEx.Replace(ABC123, ABC#*123, ., roIgnorePatternSpace); Memo1.Lines.Add(rStr); /.123 rStr := TRegEx.Replace(ABC123, ABC#*123, .); Memo1.Lines.Add(rStr); /.end;*.,A B C,AB CABC,A B C,.-.123.*選項集合procedure TForm1.Button7Click(Sender: TObject);const pattern =
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 血管外科急危重癥診療要點
- 痔瘡嵌頓的護理
- 培訓闖關游戲課件
- 中學行政培訓:提升管理智慧共筑教育合力
- 冬天保暖知識教育
- 康復科護理查房
- QC外出培訓總結
- 全國教師教育發(fā)展大會實施綱要
- 養(yǎng)老機構如何借助醫(yī)養(yǎng)結合模式實現2025年高質量發(fā)展報告
- 航空貨運行業(yè)2025年市場競爭態(tài)勢與發(fā)展戰(zhàn)略規(guī)劃報告001
- 初中數學北師大八年級下冊(2023年修訂) 因式分解岷陽王冬雪提公因式法教學設計
- 金屬非金屬礦山安全規(guī)程
- 生活飲用水游離余氯方法驗證報告
- DB32∕T 186-2015 建筑消防設施檢測技術規(guī)程
- C-TPAT反恐知識培訓ppt課件
- 巡檢培訓課件.ppt
- 二代征信系統數據采集規(guī)范釋義
- 軸承基礎知識PPT通用課件
- 蘇教版二年級(下冊)科學全冊單元測試卷含期中期末(有答案)
- 河南華泰特種電纜項目可行性分析報告
- 公司員工合理化建議獎勵辦法
評論
0/150
提交評論