Page 1 of 1

Commenting out block of lines

Posted: Thu Feb 14, 2002 2:34 pm
by Rob Nicholson
I'm trying to delete out a block of lines based on a regular expression as shown below. I want to delete the following VisualBasic interface which isn't used anymore.

I've tried replacing:

Private Property Get IFeature_Templates.*End Property

with nothing but that doesn't work as . doesn't match end of lines?

Any ideas?
Thanks, Rob.

Private Property Get IFeature_Templates() As JadeObject.CCollection
Set IFeature_Templates = Product.Templates
Dim Parent As ISReqParent
Set Parent = m_Object.Parent
Set IFeature_Templates = Parent.FindProdFromRequestType(Me).Templates
End Property

Re: Commenting out block of lines

Posted: Fri Feb 15, 2002 5:01 pm
by Andreas
use \n to match linebreaks - but you can't use + or * on \n ...

Re: Commenting out block of lines

Posted: Sat Feb 16, 2002 2:24 pm
by Rob Nicholson
That's the problem isn't it :-) Even the $ character doesn't work. I'm sure there must be a way as commenting out an block of lines which are delimited by two tokens must be done quite frequently.

Cheers, Rob.

Re: Commenting out block of lines

Posted: Sun Feb 17, 2002 4:58 pm
by xartica
Although TextPad is one of my most-cherished applications,
I haven't found a textpad-based solution (a suitable RegExp) for
performing interline deletions or replacements.

For these replacements (and deletions), I depend upon a program called
XReplace32. (see http://xreplace.vestris.com/ )

I've used it to bulk replace portions of HTML documents ~~ pull in a copy of HTML pages from a website I've authored, without worrying about whether each document was authored in a Unix environment or on a Windows PC
(different end-of-line chars to try to match)...

...and replace the contents of a named <div>, for instance. XReplace lets you "split" the text you're interested in replacing, so you can say "look for <div id="navbar"> and perform a replacement all the way up to, and including, the next string that matches '</div>'.

The example I gave is analagous with what you are wanting to do:

replace/nix everything between
"Private Property Get IFeature_Templates."
and
"End Property"

For every matching instance found.

Re: Commenting out block of lines

Posted: Mon Feb 18, 2002 1:57 pm
by Rob Nicholson
Thanks for the recommendation. I'll check out X-REPLACE. Maybe one for the TextPad wishlist?

Cheers, Rob.

Re: Commenting out block of lines

Posted: Wed Feb 20, 2002 12:01 am
by Roy Beatty
Forty bucks for the full version seems steep, even to a regex junkie like me! What does this utility add that Python or Perl lack?

Just curious,

Roy

Re: Commenting out block of lines

Posted: Fri Feb 22, 2002 12:01 pm
by Rob Nicholson
If X-Replace saves use just one hour of work, it's paid for itself. As non-web, Unix skilled person, I like the idea it's not Perl :-) Tried the shareware version and learnt what I needed to do in 15 mins. Not sure the same would be true of Perl.

But should we be talking about a competitor?

Rob.

Re: Commenting out block of lines

Posted: Fri Feb 22, 2002 4:12 pm
by Mark Schnitzius
Have you considered using a macro? Just define one that searches for your ending condition (End Property) with "Extend Selection" checked, then deletes it.

Re: Commenting out block of lines

Posted: Mon Feb 25, 2002 10:24 am
by Rob Nicholson
That's a good suggestion but requires you to visit each file one by one, running the macro. The great thing about replace is that is can very quickly replace through hundreds of source files.

Cheers, Rob.