Delete specific lines in file
-
Hello, i have a very long file and i want to search for specific lines and delete them. The lines i want to remain are the ones with the numbers [0], [1] and [2]. The rest [3],[4],[5] and [6] i want to delete but anyway in my file i have more than this, this is just an example.
low_intensity_minimum[0]: &12431270 low_intensity_minimum[1]: &31025270 low_intensity_minimum[2]: 3 low_intensity_minimum[3]: &310531270 low_intensity_minimum[4]: &31352270 low_intensity_minimum[5]: &31531270 low_intensity_minimum[6]: &315661270 dark_adaptation_speed[0]: 7 dark_adaptation_speed[1]: &2f532531 dark_adaptation_speed[2]: &3f154511 dark_adaptation_speed[3]: &37373737 dark_adaptation_speed[4]: 1 dark_adaptation_speed[5]: &262462 dark_adaptation_speed[6]: &2624624 wind_type[0]: 2 wind_type[1]: 1 wind_type[2]: 0 wind_type[3]: 0 wind_type[4]: 2 wind_type[5]: 1 wind_type[6]: 2 cloud_shadow_texture[0]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain2.tobj" cloud_shadow_texture[1]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain1.tobj" cloud_shadow_texture[2]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain4.tobj" cloud_shadow_texture[3]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain2.tobj" cloud_shadow_texture[4]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain1.tobj" cloud_shadow_texture[5]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain5.tobj" cloud_shadow_texture[6]: "/model/skybox/clouds_shadow/textures/clouds_shadow_rain4.tobj" fog_color[0]: (&373fad2e, &37732161, &337744fd) fog_color[1]: (&3wegad2e, &37732161, &43744fd) fog_color[2]: (&3752d2e, &37732161, &37d744fd) fog_color[3]: (&373fad2e, &335232161, &37d5244fd) fog_color[4]: (&373fad2e, &37232161, &37d744fd) fog_color[5]: (&37322e, &37732161, &37d2644fd) fog_color[6]: (&373fad2e, &326332161, &326744fd)
-
@Raoul-Emil
Find/replace form, go to theMark
tab (Ctrl+M using default keyboard shortcuts)Settings:
Bookmark line
: ON
Purge for each search
: doesn’t matter (I recommend on; it’s a useful default)
Backward direction
andMatch whole word only
: disabled b/c using regular expressions
Match case
: doesn’t matter
Wrap around
: on
Search mode:Regular expression
FIND:
\[[012]\]:
This will match an open squarebrace, the digit 0, 1, or 2, a close squarebrace, and a colon
Click theMark All
button. This will bookmark the lines that you want to keep.
From the main menu:Search->Bookmark->Remove Non-Bookmarked lines
This will remove all the lines you don’t want.
-
Hello, @mark-olson, @raoul-emil and All,
Mark, in your reply to @raoul-emil, I suppose that the string to find and mark is :
[\\[012\\]]:
( and not[[012]]:
)Best Regards,
guy038
P.S. :
To understand your error, refer to :
https://community.notepad-plus-plus.org/topic/21925/faq-desk-formatting-forum-posts
-
My columns are from [0] to [30]. If i want to find by using [[012]]: expression, there will be also marked the numbers [10],[11] and [12] , but i want them deleted.
I want to mark only the rows with [0], [1] and [2].
Anyway,i can mark with normal text,no need for regular expression. But i didn’t know about the mark feature. -
Hello, @raoul-emil, @mark-olson and All,
Ah…, OK. In that case, search and mark, using this regex syntax :
\\[0\\]|\\[1\\]|\\[2\\]
Best Regards,
guy038
-
@Mark-Olson said in Delete specific lines in file:
FIND: [[012]]:
Yeah, I’m aware that my regex was wrong.
I intended to enter
\\[[012]\\]
, but apparently even after the recent upgrades to the forum it still has the issues with escaped squarebraces.I had to test to see if the issue was still there, but didn’t have time to fix my post after it came out wrong.