开发者

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

开发者 https://www.devze.com 2023-02-26 09:36 出处:网络
A /n /n /n . . B 开发者_StackOverflow中文版 Now there can be n no of lines between a and b have to find such content and remove A and BSimple Regex like
 A
 /n
 /n
 /n
 .
 .
 B
开发者_StackOverflow中文版

Now there can be n no of lines between a and b have to find such content and remove A and B


Simple Regex like

(A)(.*)(B)

would suffice. Add ^ and $ based on start and end. If A and B are start and end respectively use

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

Extract the appropriate group.

To make it a bit more complex and without having to use groups, use:

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

You have to use RegexOptions.Singleline to make . match line breaks.

Edit after comment:

Oh my god, you could have been clearer.

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.

For available expressions and more details : http://msdn.microsoft.com/en-us/library/2k3te2cs(v=VS.100).aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消