Community
    • Login

    Want to set an algorithm to search

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 698 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.
    • Вадим БелянскийВ
      Вадим Белянский
      last edited by

      Hello, I need to get a specific search result in text. I need to find lines where only certain numbers are greater than “x”. How can i made it? Sorry for my bad english, i hope you understand me

      1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R
        last edited by

        @Вадим-Белянский said:

        I need to find lines where only certain numbers are greater than “x”

        As a short answer, it is NOT possible. Regex (regular expressions) have no ability to look for “greater than” or “less than” an amount. So no mathematical ability.

        However there is a way around it depending on the number. In regex we can look for numbers that are x digits long, so if you are looking for a number greater than 999 we could say \d{4,} which means any number as long as it is 4 digits or more long.

        If you wanted to say look for something greater than 345, then it becomes very difficult. Firstly we’d be looking for 4 digits or more, then for any 3 digits long we’d need to have first digit being 4-9. Then below that we continue checking 2nd digit and 3rd digit. Hopefully you understand my meaning.

        So not impossible, just difficult.

        Terry

        1 Reply Last reply Reply Quote 4
        • Terry RT
          Terry R
          last edited by

          @Вадим-Белянский said:

          How can i made it?

          As an exercise that might help explain the method I outlined before.
          Say we are looking for numbers greater than 229. I have the following numbers as an example

          234
          229
          245
          1000
          199

          So the regex to mark these lines containing the numbers I want is:
          Find What:(\d{4,})|([2-9][3-9]\d)
          If you have “bookmark line” also ticked on the Mark function you will see it marks
          234
          245
          1000
          only

          This is only a simple example, the longer the number of characters the more complicated the regex becomes. Whilst it will work it is NOT the most efficient method. In english it can be likened to hitting a pin with a sledgehammer to push it in.

          Terry

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