How to display only rows that contain the number "300000"



  • How to display only rows that contain the number “300000” and delete the remaining rows.

    I have lot of rows wit some information and it`s ended some number example ;3876219
    How to display only rows that contain the number “300000”



  • @djmcg said:

    display only rows

    As far as displaying only those lines goes, you are probably out of luck. Deleting lines that don’t contain a certain thing can be accomplished, but in a roundabout way:

    You can do it with standard Notepad++ but for this task I might recommend the LineFilter2 plugin…

    The easiest way to do it in Notepad++ itself is probably to mark the lines that contain 300000 and then copy them to a new tab. Invoke the Search (menu) -> Mark… dialog and set up the fields. Make sure to tick Bookmark line. Run it and all of the lines that match your desired text will get “bookmarked” with a round blue ball in the left margin. Next invoke Search (menu) -> Bookmark -> Copy Bookmarked Lines. Then paste the clipboard contents (containing only lines with your desired data) somewhere else (e.g., a new tab).

    There are other ways but that may be the simplest to explain and execute…but wait, maybe this is even easier:

    Do a FInd All in Current Document for your data. The right-click in the Find result panel’s whitespace area and choose Select All. Again right-click and choose Copy. Then paste the clipboard contents (containing only lines with your desired data) somewhere else (e.g., a new tab).

    You’ve got options! :-D



  • Hello, @djmcg, @scott-sumner and All,

    I said, in that other post, below, that finding all files, which do not contain a specific string, was not easy, with our Boost regex engine and that we need to use a work-around to get the right results. However, we can easily build a regex which find all lines of files, which do not contain a specific string ! And, then, delete them, as and when :-))

    https://notepad-plus-plus.org/community/topic/14870/regex-find-all-files-that-do-not-contain-some-words/2


    In your example, this specific string seems to be the number 300000, preceded by a semicolon

    So, the regex S/R, below, should keep only lines containing the string ;300000 :

    SEARCH (?-s)(?!.*;300000)^.*\R

    REPLACE Leave EMPTY

    OPTIONS Regular expression and Wrap around checked

    => It remains, only lines that contain the string ;300000. Et voilà !


    Notes :

    • The first part (?-s) modifier means that dot will match any standard character, only and NOT the line breaks

    • The last part ^.*\R is the range of characters to search for, that is to say, all characters of a line, even empty, along with its End of Line character(s)

    • And, thanks to the middle part (?!.*;300000), which is a negative look-ahead, this search will be true, ONLY IF the string ;300000 cannot be found, from beginning of line, in the current line scanned

    • And, as the Replacement part is empty, these lines are simply deleted


    As you see, you’ve got 4 solutions, to get the job done :

    • With the LineFilter2 plugin

    • With bookmarks

    • With the Find result panel

    • With regex S/R

    Enjoy N++ !!

    Cheers,

    guy038


Log in to reply