Community
    • Login

    are searching for strings with varying amounts of spaces / data in between, possible?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 839 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.
    • Frederick SoleboF
      Frederick Solebo
      last edited by

      Hi guys, my first time posting here… Let’s say a paragraph reads as follows (in quotes):

      “The sky is blue.
      The sky is very blue.
      A red sky can even possibly turn 336699 blue today.”

      Using notepad++, is it possible for me to do some type of search that will find me all instances of the word “sky” following by any number of characters (numbers and/or letters), followed by the word “blue”? There are 3 total instances of this situation in the paragraph above, but notice that the data in between “sky” and “blue” on each line / instance is not consistent; it could be varying lengths of data, it could be numbers, it could be letters, different amounts of spaces, etc. I realize that doing a find for “sky” asterick “blue” won’t do the job.

      Is what I’m asking possible? Also, what’s the name for this type of search?

      Thanks,
      Fred

      Scott SumnerS 1 Reply Last reply Reply Quote 1
      • Scott SumnerS
        Scott Sumner @Frederick Solebo
        last edited by

        @Frederick-Solebo

        Yes, very possible with the use of Regular expression search as follows:

        Find what zone: (?-is)sky.+blue
        Search mode: Regular expression

        You should be able to deduce what the .+ does.
        The (?-is) at the beginning indicates 2 things:

        • case of sky and blue must match exactly (the -i part)
        • the . will NOT match end-of-line characters (the s part, but note that the - from earlier effectively makes this -s)

        Probably this is confusing, so a better explanation is that the i stands for (case) insensitive, so -i means NOT case insensitive, or rather case sensitive (meaning case must be exact for a match to occur)

        A better explanation for the s part: (?s) means that any . characters occurring will match one character of any type (including end-of-line characters). (?-s) means that any . characters occurring will match one character of any type EXCEPT it won’t match the end of line characters (carriage return, line feed).

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