regular expression – EmEditor (Text Editor) https://www.emeditor.com Best Text Editor, Code Editor, CSV Editor, Large File Viewer for Windows (Free versions available) Tue, 28 Aug 2018 14:38:08 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 Question of Regular Expression for matching multi-row https://www.emeditor.com/forums/topic/question-of-regular-expression-for-matching-multi-row/ Tue, 28 Aug 2018 14:37:32 +0000 https://www.emeditor.com/forums/topic/question-of-regular-expression-for-matching-multi-row/ Hello, Anyone knows how to match multi-line via Regular Expression?

There are some similar format files. some lines are fixed (same contents). I would like to search and add something inside.
Example :
`1000 function main takes nothing returns nothing</strong>
1001 call SetMapMusic(“Music”, true, 0)
1002 call CreateAllItems()
1003 call CreateAllUnits()
1004 call InitBlizzard()
……..
1100 set udg_str=”” // INLINED!!
1101 call InitCustomTriggers()
1102 endfunction`

The start row “function main takes nothing returns nothing” and end “endfunction” are fixed contents. But the row number and the gap between these two rows are unfixed. Since the row “endfuntion” is possible to exist alone. Then I have to consider start row and end row. But I don’t know how to match unfixed multi-row. Could you give me some hints.? Thank you!

]]>
Bug in regular expression find, both in green-coloring and actual finding https://www.emeditor.com/forums/topic/bug-in-regular-expression-find-both-in-green-coloring-and-actual-finding/ Thu, 14 Jul 2016 23:32:49 +0000 https://www.emeditor.com/forums/topic/bug-in-regular-expression-find-both-in-green-coloring-and-actual-finding/ While trying to search for “lines not beginning with a tab, and also followed by an empty line”, I found some strange behavior in the EmEditor Find function that clearly seems like bugs to me, as follows:

The following regular expression works as expected (finds and colors green all lines that do not begin with a tab):

^[^\t].*

As soon as I add a linebreak though, the green-coloring of search results stops working completely. The actual finding of the lines still works though (the lines are selected in grey and jumped to correctly when pressing “Find next”):

^[^\t].*\n

If adding another linebreak to the regular expression though, both the green-coloring and the correct finding of the lines stop working completely though, and seemingly completely random lines are identified as “found” (I tried bookmarking the found lines from the Find dialog, since this was the only way of identifying them at all with the highlighting not working correctly):

^[^\t].*\n\n

I am not using any special search settings, and all checkboxes are unchecked in the “Advanced…” dialog of the Find dialog. Also I tried using both regular expression engines without any difference.

ADDITION:
I just noticed that the inability to find the correct lines happens only when the filter function is used (typically when there is really a line following the seemingly single lines, but it has been filtered away), but the lack-of-green-coloring bug happens no matter if there is a filter applied or not, so it’s a separate bug.

Here is a test case:

Try to use the regular expression ^[^\t].*\n\n on the following, without any filtering, and you will see that the green-coloring of search results will be missing:

aaa

bbb

ccc
111

ddd

eee

Now, filter away the line containing the “111” (and a tab before it) and try to search again with the same regexp, and you will see that the “ccc” line will still not be matched, although it should be now (since it is also a “single line” after that filtering-away of the subsequent “111” line).

]]>