Community
    • Login

    bookmarks line with value numbers

    Scheduled Pinned Locked Moved General Discussion
    4 Posts 2 Posters 645 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • namx3249N
      namx3249
      last edited by

      hi great community,

      i’ve some document like this:

      text chw
      12.34 aa
      text gsh
      
      text als
      18.57 aa
      text owp
      
      text wal
      35.81 aa
      text gph
      

      i need to bookmaks all lines with value below 14.00 aa
      so, from the example above, the second line with 12.34 aa value
      how to ?

      PeterJonesP 2 Replies Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @namx3249
        last edited by PeterJones

        @namx3249 ,

        In general, searches cannot do math (add, subtract, compare matched value to a real value like 14.00), even the “regular expression” syntax.

        However, with some data, it’s possible to overcome this limitation by a more-complicated regular expression.

        For your data as presented, with some simple assumptions I will enumerate, it’s possible and not too onerous.

        Assumptions

        • All numbers that will match:
          • start at the beginning of the line (no leading spaces)
          • will be unsigned (no - or + before them)
          • have at least one digit before the decimal point
          • have exactly two digits after the digits
        • You want to match and bookmark any that are from 0.00 - 13.99, followed by a space and two lowercase letter a characters. 14.00 aa will not be matched or bookmarked, because it is not below 14.00. 1.23 ab will not match because it’s got ab not aa.

        Procedure

        • Search > Mark
        • FIND WHAT = ^(\d|1[0123])\.\d{2} aa
        • mark the checkbox ☑ Bookmark Line
        • mark the checkbox ☑ Purge for each search (assuming you _want _ to reset the marks every time)
        • Search Mode = Regular Expression
        • MARK ALL

        FIND explanation

        • ^ = start match at start of line
        • (...) = a “group”, which I’m using as a wrapper
        • | = the | is the symbol for “OR”; I put it in a group so that (A|B) will match A or B
        • \d = a single digit (0-9)
        • 1[0123] = matches a 1 followed by 0 or 1 or 2 or 3
        • thus, (\d|1[0123]) = matches either 0-9 or 10-13
        • \. = matches a literal . decimal point
        • \d{2} = matches two digits (so 00 - 99)
        • everything remaining matches literally

        ----

        Thank you for putting your text in a text block.

        Useful References

        • Notepad++ Online User Manual: Searching/Regex
        • FAQ: Where to find other regular expressions (regex) documentation
        1 Reply Last reply Reply Quote 4
        • PeterJonesP
          PeterJones @namx3249
          last edited by

          @namx3249 ,

          I just noticed that this is your third regex topic. Please read and understand the concepts below.

          —

          Please note: This Community Forum is not a data transformation service; you should not expect to be able to always say “I have data like X and want it to look like Y” and have us do all the work for you. If you are new to the Forum, and new to regular expressions, we will often give help on the first one or two data-transformation questions, especially if they are well-asked and you show a willingness to learn; and we will point you to the documentation where you can learn how to do the data transformations for yourself in the future. But if you repeatedly ask us to do your work for you, you will find that the patience of usually-helpful Community members wears thin. The best way to learn regular expressions is by experimenting with them yourself, and getting a feel for how they work; having us spoon-feed you the answers without you putting in the effort doesn’t help you in the long term and is uninteresting and annoying for us.

          1 Reply Last reply Reply Quote 2
          • namx3249N
            namx3249
            last edited by

            wow, great solution. wonderful
            it work fine, thank you Peter

            about your second post: i agree, and i’ve try to search around the web some solution, but i didn’t find anything useful, and few have the knowledge as you have
            I hope in the future to increase my notions, in fact i’m following all the threads here!

            all the best

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors