Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (https://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   Problem with Replace in File (https://www.kinook.com/Forum/showthread.php?t=317)

GrahamS 02-06-2004 08:02 AM

Problem with Replace in File
 
I'm trying to use Replace In File to delete all lines that contain a certain phrase. I'm using the following regular expression to find the line, together with blank replacement text

^.*Delete Me.*$


If no line contains the phrase then I get the complete file echoed (as expected). However, if any line in my file contains the phrase then all text is deleted.

What is going wrong?

kinook 02-06-2004 09:59 AM

.* will match any character (including end of line) any number of times (to the end of the file). Also, $ will only match the end of the line (exclusive of the CR/LF chars), so the line will be cleared but not removed. Something like this should work:

^[[^\r]]*Delete Me[[^\r]]*\r\n


All times are GMT -5. The time now is 02:53 PM.


Copyright © 1999-2023 Kinook Software, Inc.