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 1.1k Views 2 Watching
    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 Offline
      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 Offline
        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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors