簡體   English   中英

如何使用Regx檢查n個單詞之間的n行替換?

[英]How to check n number of the lines between words using Regx for find n replace?

 A
 /n
 /n
 /n
 .
 .
 B

現在a和b之間沒有n行可以找到此類內容並刪除A和B

簡單的正則表達式喜歡

(A)(.*)(B)

就足夠了。 根據開始和結束添加^$ 如果A和B分別是開始和結束,請使用

^(A)(.*)(B)$

提取適當的組。

為了使其更加復雜並且無需使用組,請使用:

(?<=A)(.*)(?=B)

您必須使用RegexOptions.Singleline進行制作. 匹配換行符。

評論后編輯:

哦,天哪,你本來可以更清楚的。

To enable regular expressions, expand Find options in the Find and Replace window,
select Use, and then select Regular expressions. The triangular Expression Builder 
buttons next to the Find what and Replace with fields become available. Click the 
button to display a list of frequently used regular expressions.

有關可用的表達式和更多詳細信息,請訪問: http : //msdn.microsoft.com/zh-cn/library/2k3te2cs(v=VS.100).aspx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM