Stripping out all lines beginning with ;

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
User avatar
mmiller
Posts: 17
Joined: Tue Nov 25, 2003 11:49 pm
Location: Canada
Contact:

Stripping out all lines beginning with ;

Post by mmiller »

Hi Folks;

I bought TextPad years ago and I use it every day - it's great!

I have a question - I'm editing PHP.ini files and I'd love to be able to strip out all the rem lines that begin with ;

Here's an example;
;;;;;;;;;;;
; WARNING ;
;;;;;;;;;;;
; This is the default settings file for new PHP installations.
; By default, PHP installs itself with a configuration suitable for
; development purposes, and *NOT* for production purposes.
; For several security-oriented considerations that should be taken
; before going online with your site, please consult php.ini-recommended
; and http://php.net/manual/en/security.php.


;;;;;;;;;;;;;;;;;;;
; About this file ;
;;;;;;;;;;;;;;;;;;;
; This file controls many aspects of PHP's behavior. In order for PHP to
; read it, it must be named 'php.ini'. PHP looks for it in the current
; working directory, in the path designated by the environment variable
; PHPRC, and in the path that was defined in compile time (in that order).
; Under Windows, the compile-time path is the Windows directory. The
; path in which the php.ini file is looked for can be overridden using
; the -c argument in command line mode.
All of that should be deleted with no blank lines left after deleting.

Does anyone know how to do that?
Best Regards;
Marvin Miller
gan

Post by gan »

You could use search and replace with regular expression, but i guess you have to run it a couple of times. Depending what you want to do.

If you want to remove all the lines that start with a ";" you could use this search string:

Code: Select all

^;.+\n
If you want to remove all blank lines you could use this search string:

Code: Select all

^\n
Both should be replaced with nothing of course. If you want to keep other blank lines except those inbetween rem lines it could be a bit harder.

If there is always two blank lines inbetween the rem lines you could use this search string:

Code: Select all

(^;.+)\n\n\n(^;)
and replace with this:

Code: Select all

\1\n\2
The last example should be used before the rem lines is removed of course. This should work for your current example running search and replace two times, but there could be many other combinations that doesn't match which you didn't mention. If the number of blank lines inbetween the rem lines vary you might have to run search and replace a couple of more times using a search string that is a bit different.

If this cannot be used for some reason a bit more information how the rem lines might look could be useful. Removing all lines that start with ";" is easy, but it's about the blank lines inbetween that might be a challenge unless it's ok to remove all blank lines no matter where they are. If you manage to use regular expression to remove what you want you could create a macro that will run them in order instead of you manually have to do a search and replace several times using different search strings.

Regular Expression have to be checked during the search and replace of course.
User avatar
mmiller
Posts: 17
Joined: Tue Nov 25, 2003 11:49 pm
Location: Canada
Contact:

Post by mmiller »

Thanks Gan - that worked well :D
Best Regards;
Marvin Miller
Post Reply