are searching for strings with varying amounts of spaces / data in between, possible?
-
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 -
Yes, very possible with the use of Regular expression search as follows:
Find what zone:
(?-is)sky.+blue
Search mode: Regular expressionYou should be able to deduce what the
.+
does.
The(?-is)
at the beginning indicates 2 things:- case of
sky
andblue
must match exactly (the-i
part) - the
.
will NOT match end-of-line characters (thes
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). - case of