I'm using TextPad 7.0.9.
I want to delete lines that begin with a tab. My RE is deleting every other line instead of every line. What's bothering me is that it works when I step through the text deleting each line by line. It doesn't work when I do replace all. My file is too large to replace each line by itself. In my example I'm using <tab> to represent a tab character:
example:
<tab>1<tab><tab><tab>
<tab>2<tab><tab><tab>
<tab>3<tab><tab><tab>
<tab>4<tab><tab><tab>
result:
<tab>2<tab><tab><tab>
<tab>4<tab><tab><tab>
Find: ^\t[^\r]*\R
Replace with: null
I've tried almost every combination of \r\n, just \n, \R, or $ at the end of the RE and in the character class. They all give the same result. Thanks in advance.
RE Deleting Every Other Line Instead of Every Line
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 13
- Joined: Tue Feb 15, 2005 1:00 am
Code: Select all
^\t.*\n
-
- Posts: 13
- Joined: Tue Feb 15, 2005 1:00 am
-
- Posts: 13
- Joined: Tue Feb 15, 2005 1:00 am
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
The simpler regex suggested by MudGuard should work: the [^\r] (as opposed to a simple dot) in the original regex is unnecessary.
But neither of these regexes does work. When running a Replace All, replacing anything like ^.*\n with nothing, the recogniser misses out every other line. It seems that it fails to match ^ at the beginning of a line when it has just removed the preceding newline. This is a bug. Strangely, however, parenthesising the ^ seems to fix the problem.
So using (^)\t.*\n solves the problem.
But neither of these regexes does work. When running a Replace All, replacing anything like ^.*\n with nothing, the recogniser misses out every other line. It seems that it fails to match ^ at the beginning of a line when it has just removed the preceding newline. This is a bug. Strangely, however, parenthesising the ^ seems to fix the problem.
So using (^)\t.*\n solves the problem.