Search in files
-
Hello, can I do a file search (Ctrl + Shift + F) of two words on the same line? thanks.
-
I guess, yes.
-
Hello, @francisco and All,
A short example :
Let’s suppose you’re looking for all the lines of all files, in a specific directory, containing, both, the two strings
YouandthereThree questions arise :
-
Do you mind the case of the strings or not (
YOU,There,yoU,THEre, … ) -
Do you mind if the strings
Youandthereare true words or part of words likeYourandtherefore? -
Does the string
Youalways come before the stringthereor the opposite or both situations may occur ?
So, here are
4regular expressions for each case. Note that I suppose that, both, word_1 or word_2 may occur first, in current line :-
Regex A :
(?-is)You.*there|there.*Youfor a search of stringsYouandthere, with this exact case -
Regex B :
(?i-s)You.*there|there.*Youfor a search of stringsYouandthere, whatever their case -
Regex C :
(?-is)\bYou\b.*\bthere\b|\bthere\b.*\bYou\bfor a search of wordsYouandthere, with this exact case -
Regex D :
(?i-s)\bYou\b.*\bthere\b|\bthere\b.*\bYou\bfor a search of wordsYouandthere, whatever their case
Of course, you must select the
Regular expressionsearch modeThe
(?-s)in-line modifier ensures that the regex engine will interpret the dot (.) as matching a single standard character and not the line-break chars !Hope this helps :-)
Best Regards,
guy038
-
-
Very thanks guy038, I will try
-
Please, guyo38, help me, I have a file with some lines: I need to do a search for 144 and JU44…
144 FX 2020-06-13 1427 PU3LJY GG67 PMVUV FG67
144 FT 2020-06-13 1741 PL4JYU GG68 PH7NS HG68
144 FO 2020-06-13 1752 PM2LJY GG77 PD9MM JU44 -
Hi @Francisco,
I think you will get what you want if you replace “You” with “144” and “there” with “JU44” in @guy038’s third Regular Expression, above.
Take care.
-
Hi, @francisco and All,
Yes, as @astrosofista said, I suppose that you need the regex C of my previous post :
Thus, in your case, the regex becomes
(?-is)\b144\b.*\bJU44\bNote that I even shortened this regex as the number
144comes before the wordJU44!Best Regards
guy038
-
Now sucess, very thanks guy038 and all… Take care.
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