Tagged: CTRL + ENTER, Multiple-line
- AuthorPosts
- July 3, 2019 at 10:59 am #25938tuskaParticipant
http://www.emeditor.org/en/faq_search_search_multi-string_line.html
On the right side of the Find drop-down list box, click the > button to display a menu, and select the Multiline.
Moreover, drag the right bottom corner of the dialog box so the text box allows multiple lines.
In order to enter a new line, use CTRL + ENTER.Hi,
I have already made some searches, e.g.
– Ctrl + Shift + F: Find in Files
– Ctrl + H: Replace
with
– (None)
– with/without Regular Expressions
– Escape Sequence
but without success.Example:
1
2
3
09
4
5I want to find 2 and 4 (should be marked then).
In the search field I entered 2 Ctrl+ENTER and then 4 Ctrl+ENTER.
The cursor was placed at the beginning of the file and then the button “Find Next” was pressed.As a result I get the following message in the status bar:
“Cannot find 24 below the current position.”For me it looks like Ctrl+ENTER has no effect on multiline.
A single digit can easily be found.I therefore ask for support or a step-by-step guide, how to solve this issue.
I have only beginner’s knowledge…Windows 10 Pro (x64) Version 1903 (OS Build 18362.207)
EmEditor Professional (64-bit) Version 18.9.12Regards,
KarlJuly 3, 2019 at 12:28 pm #25939Patrick CParticipantI’m really short on time and its not the complete answer, but the regex for finding 2 or 4 is:
[24]This will however, select only one of the characters at a time.
July 3, 2019 at 2:11 pm #25940tuskaParticipant2Patrick C
Thank you for your solution.On my PC the following is marked in EmEditor (in a .txt file):
2 4 24
and I am very happy with that (because it is the first time that anything is marked at all).
How I can find e.g. with RegEx
– exact number 2 and 4
– the number 2 and 09
I have to learn first (RegEx).Thanks again.
Regards,
KarlJuly 3, 2019 at 2:19 pm #25941tuskaParticipantHowever, I still don’t know what a solution without RegEx knowledge looks like,
i.e. for which example CTRL + ENTER is to be used.Please support me on this question.
July 4, 2019 at 2:06 am #25942tuskaParticipantHere is a picture:
July 5, 2019 at 6:04 am #25947LTTParticipantCtrl+Enter (in Multi-line mode) = \n (in Single-line mode).
If you want to search for a multi-line string, usually you have to match the exact number of the lines:
2\n.*\n4 matches:
2
anything
42\n.*\n.*\n4 matches:
2
anything
anything
4All in this post are Regular Expressions:
http://www.emeditor.org/en/howto_search_search_regexp_syntax.htmlAnd note that EmEditor cannot highlight multi-line matches with colors.
—————
If the number of lines is uncertain, open “Advanced…”:Additional Lines to Search for Regular Expressions:
Enter a number (the maximum for your case).
[★The help for this option is important.]
(Don’t forget that in such dialog boxes you can press F1 for help.)** But currently you have to relaunch EmEditor to make the change effective. (It could be a bug.)
Expression 1:
2[\s\S]*4 should now work for you.Expression 2:
Open “Advanced…”:
Enable: Regular Expressions “.” Can Match Newline Characters.
2.*4 should also work now.—————
While “Find in Files” is different:
(It doesn’t need “Additional Lines to Search for Regular Expressions”.)2[\s\S]*4 always works.
2.*4 works only if you enable the option:
Regular Expressions “.” Can Match Newline Characters.
[★The help for this option is important.]I have to say the design for such multi-line searches in EmEditor is complicated and inconvenient…
July 5, 2019 at 7:31 am #25950tuskaParticipant2LTT
Thank you very much for your examples with RegEx and efforts to bring the topic closer to me.
Unfortunately, I’m afraid I’m more confused now than before.Ctrl+Enter (in Multi-line mode) = \n (in Single-line mode).
If I do CTRL + ENTER as in the picture above, I won’t get any results with the following options:
☑ Multiline
◉ (None)
◉ Regular Expressions
◉ Escape SequenceIs this a bug of EmEditor or an application error of mine?
Are multi-line queries only allowed with the option ◉ Regular Expressions?If you want to search for a multi-line string, usually you have to match the exact number of the lines:
Does this mean that I have to go to the end of each text document before searching to determine the exact number of lines?
And note that EmEditor cannot highlight multi-line matches with colors.
Mmmh, with
☑ Multiline
◉ Regular Expressions
(^2$|^4$)
in a .txt file the numbers 2 and 4 are marked in green.In the example in the picture I wanted to find exactly the numbers 2 and 4 in a range from 1 to 5, with or without RegEx.
To complicate matters, I would also like to add the number 24 to the list and this number should not be marked.
Unfortunately, I do not know how it would be possible to make an exact definition, so that only numbers 2 and 4 would be marked.Perhaps it would be possible if you or someone else could answer these questions for me.
July 5, 2019 at 8:45 am #25951tuskaParticipantIf you want to search for a multi-line string, usually you have to match the exact number of the lines:
Does this mean that I have to go to the end of each text document before searching to determine the exact number of lines?And note that EmEditor cannot highlight multi-line matches with colors.
Mmmh, with
☑ Multiline
◉ Regular Expressions
(^2$|^4$)
in a .txt file the numbers 2 and 4 are marked in green.Please regard this text as irrelevant.
That was a misunderstanding on my part.For me, there are currently only two questions left unanswered:
– CTRL + ENTER (see previous post)
– Exact search for a number with RegEx, e.g. find 2 and 4 in a range from 1,2,3,4,5,24 (see previous post).July 5, 2019 at 10:37 am #25952Patrick CParticipantWelcome to the regex kitchen stew (semi serious; regex seems to drive most people I know either mad or desperate or both)
Anyway one possible RegEx for finding 2 or 4 but not 24 is:
(2(?!4)|(?<!2)4)Which works on
1
2
3
09
4
5
24
51
1,2,3,09,4,5,24,51,4,2,42,8,4,6,2,8
2
4To get an idea on what this does
(a|b)
finds either a or b, where
a = 2(?!4) finds 2 without a trailing 4
b = (?<!2)4 finds 4 without a leading 2Note that I’m not a regex guru.
July 5, 2019 at 10:37 am #25953Patrick CParticipantTip: My preferred tool for testing out and learning regex is
regex101 dot comJuly 5, 2019 at 1:50 pm #25954tuskaParticipant2Patrick C
Thank you for your code, which is the solution for my example above.
Your example also finds the number 42 – this should not be found.I don’t know if there is a solution:
Only 2 and 4 should be found, i.e. exactly:2 and exactly:4.If there are any combinations in which the numbers 2 and 4 are contained,
such as 1024, 42, 4242, 1524, 2415, 124215, 754224, etc., then the numbers should not be found/marked.regex101 dot com is also my favorite site because it offers explanations – but I am a complete beginner…
July 5, 2019 at 2:14 pm #25955Mr KTParticipantHi Tuska,
try this (just with regular expressions radio button on):(?<![0-9])[24](?![0-9])
Explanation:
(?<![0-9]) means negative look-behind, check no number before 2 or 4
[24] means find 2 or 4
(?![0-9]) means negative look-ahead, check no number after 2 or 4July 6, 2019 at 2:07 am #25956tuskaParticipantHi Mr KT,
(?<![0-9])[24](?![0-9])
works perfectly!
Thank you very much.July 6, 2019 at 2:16 am #25957tuskaParticipantFor me, there is currently only one question left unanswered: CTRL+ENTER (in Multi-line mode) – (see previous post):
If I do CTRL + ENTER as in the picture above, I won’t get any results with the following options:
☑ Multiline
◉ (None)
◉ Regular Expressions
◉ Escape Sequence
Is this a bug of EmEditor or an application error of mine?
Are multi-line queries only allowed with the option ◉ Regular Expressions?July 6, 2019 at 4:02 am #25958LTTParticipantSo it turned out you were not really searching for multip-line strings…
No need to use that Multiline mode unless you want to match a multi-line string.
That box in Multiline mode is not a “list”, if you thought it was.
If the above is enough to answer the last question, don’t read further in case you will be confused again. ;)
——————————
As for Multiline mode with search options:If you turn on “Multiline” with “(None)”, only exact-text searches can be done.
e.g. in Find box:
2
3
4
only matches as a whole:
2
3
4However, EmEditor does such a search using “Escape Sequence” internally.
The expression is saved as “2\n3\n4”. And if you turn off “Multiline”, “Escape Sequence” will be turned on automatically.So, to search for a multi-line string,
either you always use Multiline mode with “(None)” to do an exact-text search,
or, turn on “Escape Sequence” at least and use “\n”.Escape Sequence syntax is very simple. See it in the menu of the “>” button.
A common text search only needs \n \t \\ when necessary.Use Regular Expressions if the content/length of the matches is uncertain.
——————————
>… are marked in green.EmEditor cannot highlight multi-line matches with colors.
A match will be highlighted with colors unless it’s multi-line.July 6, 2019 at 4:34 am #25959LTTParticipantMulti(ple)-line search ≠ Multiple search
July 7, 2019 at 5:11 am #25960tuskaParticipant2LTT
Many thanks for the comprehensive and detailed information.That box in Multiline mode is not a “list”, if you thought it was.
Yes, I mistakenly assumed that.
>… are marked in green.
> EmEditor cannot highlight multi-line matches with colors.
> A match will be highlighted with colors unless it’s multi-line.Yes, that’s why I wrote above:
> Please regard this text as irrelevant.
> That was a misunderstanding on my part.I think I understand the subject a little better now, but between theory and practice there’s still a gap with me.
Example:
1
2
3
4
5only matches as a whole:
2
3
41. RegEx –> OK
2. Multiple-lines –> ?Please watch the video:
20190707_13.32.43_Video__1368x836_00.02.24_Multiple-line string as a search string.wmvWhat am I doing wrong with “Multiline” or what else is a mistake of mine?
July 7, 2019 at 7:47 am #25962LTTParticipantGreat! According to your video, I think you’ve grasped almost anything!
The failure was because you enabled “Treat CR and LF Separately” in “Advanced”.
Read the last sentence at the bottom of this page:
http://www.emeditor.org/en/howto_search_search_nl.htmlLet’s see if Yutaka will optimize the Multiline mode:
https://www.emeditor.com/forums/topic/advanced-search-options/#post-25961I suggest you reset the Advanced options.
Use them only when needed.July 7, 2019 at 12:15 pm #25963tuskaParticipant2LTT
Thank you very much for your support!I have read everything from you carefully.
Now everything is working as expected.For me personally, I have noted the following as a brief summary:
With CTRL + ENTER and option “Multiline” in the “Find”-window, it is possible to search for a cohesive search term over several lines.Simple formulation for valid examples for CTRL + ENTER:
– Example1: 1,2,3,4,5 –> Search for: 2,3,4 (and not for 2,4) –> DO NOT press CTRL+ENTER after 4!
– Example2: abc def, ghi jkl, mno pqr –> Search for: (1)def (2)ghi jkl (3)mno –> after mno do NOT press CTRL+ENTER anymore!Regards,
KarlJuly 8, 2019 at 6:53 am #25964LTTParticipantWell, it’s just continuous text, if you have to use “cohesive”.
Multiline mode is just for viewing/editing clearly, when the term in single-line mode includes “\n” and makes one dizzy.
CTRL+ENTER is just for entering a newline character in that box. (= \n)
CTRL+ENTER is not for triggering the search.You surely can use CTRL+ENTER at the end, if you want to search for a term that ends with a newline character(s).
In the box is just continuous text.
It’s not a list for searching 2 or more terms simultaneously.
Compare it with “Advanced Filter” feature in Filter toolbar.July 8, 2019 at 7:25 am #25965tuskaParticipant2LTT
Thank you for the detailed description and clarification of this function!
That’s how I understood this function now.I just wanted to make a short summary of this function for me as a reminder.
—–
Thanks again to everyone for their support!July 9, 2019 at 7:11 am #25970tuskaParticipantNow I have one last question: Button “Extract” in the “Find”-window:
☑ Use Output Bar | Extract Options: Display File Names and LinesExample:
9
09
2
4
24
42
123
5467
—-
◉ Regular Expressions: (?<![0-9])[24](?![0-9])
Klick on button “Find Next” and then on “Extract” brings “Output”:“(?<![0-9])[24](?![0-9])” Untitled-3
Untitled-3(4): 2
Untitled-3(5): 4Test: OK
—-
◉ (None) – ☑ Multiline
Same example: 2 Ctrl+enter, 4 Ctrl+enter
Klick on button “Find Next” and then on “Extract” brings “Output”:“2
4
” Untitled-3Untitled-3(4): 2
Untitled-3(5): 4 seems to be missing for me in “Output”-box
—-
◉ Escape Sequence – without Multiline
Same example: 2\n4\n
Klick on button “Find Next” and then on “Extract” brings “Output”:“2\n4\n” Untitled-3
Untitled-3(4): 2
Untitled-3(5): 4 seems to be missing for me in “Output”-box
—-
With the remaining three options in “Extract Options…” I suspect partially similar combinations,
i.e. only a partial output in the “Output” box.
—-
For me there would be one line missing in the “Output” box in the example above.
Can someone please confirm this or tell me how to understand this constellation?July 9, 2019 at 9:34 am #25971tuskaParticipantOn a second thought:
Probably only the first line in which the continuous text starts is displayed in multi-line mode.
More is actually not necessary.July 17, 2019 at 8:52 am #25983LTTParticipantIf your Extract Option is “Display … Lines …”, EmEditor displays only the first line of each match in the search result.
Though “Number of Additional Lines Above/Below Matched Lines” option can be used, the additional lines are displayed with the same format.I think the Extract function is mainly for single-line/string extracting.
You can submit suggestions if you need to extract multi-line text.July 17, 2019 at 9:10 am #25984tuskaParticipant2LTT
Thank you for this additional tip!
But I won’t make a suggestion, because the existing functions are sufficient for me. - AuthorPosts
- You must be logged in to reply to this topic.