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 wordspecialin 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 searchandWrap aroundoptions -
Select the
Regular expressionsearch mode -
Click on the
Mark Allbutton -
Now, you can, either :
-
Click on the
Copy Marked textbutton and paste the clipboard contents in a new tab -
Choose the menu option
Search > Bookmark > Copy Bookmarked linesand 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 wordspecialin the next line , but can you please help me to search for range of text having the wordspecialin 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#TESTstring 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#TESTstring, itself, at any position, thanks to this specific syntax((?!#TEST).)+? -
The
-isyntax, 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.
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