Mark all text who have word searched
-
I have a text file like the folowing one:
#TEST Random TEXT | #TEST Random TEXT: Random TEXT special Random TEXT | #TEST Random TEXT: Random TEXT | #TEST Random TEXT: Random TEXT special Random TEXT Random TEXT Random TEXT Random TEXT |
I want to mark text who contain this word “special”
The result can be :#TEST Random TEXT: Random TEXT special Random TEXT | #TEST Random TEXT: Random TEXT special Random TEXT Random TEXT Random TEXT Random TEXT |
I trying to use this
^(#TEST).+?special+?\|$
but the result not correct -
I think a clarification for those that want to help is:
You want to mark multiple lines of text that occur between single empty lines, that contain the text
special
. -
@alan-kilborn Thanks For your Reply ,
The text like you see is started by#
and ended by|
I need to mark all text who have the word
special
-
Hello, @elbriak-badr , @alan-kilborn and All,
So you need to mark any range of text beginning with a
#
character, having the wordspecial
in the next line and then mark all chars till the nearest|
characterIn this case, the road map is :
-
Open the Mark dialog (
Ctrl + M
) -
Find what :
(?-is)^#TEST.+\R.+special(?s).+?\|
-
Un-tick all options
-
Tick the
Bookmark line
,Purge for each search
andWrap around
options -
Select the
Regular expression
search mode -
Click on the
Mark All
button -
Now, you can, either :
-
Click on the
Copy Marked text
button and paste the clipboard contents in a new tab -
Choose the menu option
Search > Bookmark > Copy Bookmarked lines
and paste the clipboard contents in a new tab
-
Notes,
-
The search is sensitive to case, due to the in-line modifier
-i
( so, not insensitive ! ) -
At beginning any
.
matches a single standard char ( so, not the line-endings ) -
After the word
special
, the in-line modifier(?s)
means that dot matches any character, including EOL ones
Best Regards,
guy038
-
-
@guy038 Thanks a lot , it’s working for any range of text beginning with a
#
character, having the wordspecial
in the next line , but can you please help me to search for range of text having the wordspecial
in any line ?#TEST Random TEXT | #TEST Random TEXT: Random TEXT special Random TEXT | #TEST Random TEXT: Random TEXT | #TEST Random TEXT: Random TEXT Random TEXT Random TEXT special Random TEXT Random TEXT | #TEST Random TEXT: Random TEXT Random TEXT special Random TEXT Random TEXT Random TEXT |
Results
#TEST Random TEXT: Random TEXT special Random TEXT | #TEST Random TEXT: Random TEXT Random TEXT Random TEXT special Random TEXT Random TEXT | #TEST Random TEXT: Random TEXT Random TEXT special Random TEXT Random TEXT Random TEXT |
-
Hi, @elbriak-badr , @alan-kilborn and All,
Ah…, OK. In this case, we must use the
(?s)
modifier for the entire regex.and the goal becomes :-
A) To look for any range of text, between the string
#TEST
, beginnning a line, till the nearest|
character -
B) This range must, of course, contains the word
special
-
C) The string
#TEST
, itself, must never occur, after each#TEST
string till the wordspecial
!
Thus, the appropriate regex is :
SEARCH
(?s-i)^#TEST((?!#TEST).)+?special.+?\|
Notes :
-
To achieve the C) condition, we use a negative look-ahead condition, meaning that the range of chars, after
#TEST
, till the wordspecial
, must not contain the#TEST
string, itself, at any position, thanks to this specific syntax((?!#TEST).)+?
-
The
-i
syntax, at beginning of the regex, means that the search is sensitive to case ( so not insensitive ! ) If you need a search, whatever the case, change the part(?s-i)
by(?si)
Best Regards,
guy038
-
-
Very wonderful ,
Thanks a lot @guy038 ,
that make me love notepad++ more !!I am grateful for your support.