Closed Hexaae closed 1 year ago
don't use \r\n
but only \n
in the test dialog since grepWin normalizes the line endings.
also check the box "dot matches newline" if you search over multiple lines
but I need to remove exactly all \x0d\x0a... except those lines after ^...
also check the box "dot matches newline" if you search over multiple lines
uhm... this way though it won't do what I wanted... expected results:
#
# OSD PER-WINDOW VIDEO OPTIONS
aspect0 17:10
I'm a newbie with RegEx though :(
do you actually want to remove everything except the "OSD PER-WINDOW VIDEO OPTIONS" and the value, or do you want to filter that information out and create a new file with that?
The first option will get very complicated, that regex would grow to a huge monster. The second option however is easer: just search for that and use the "Capture search" feature instead.
search string: #(?:\n|\r\n|\n\r)(# OSD PER-WINDOW VIDEO OPTIONS)((?:\n|\r\n|\n\r)#)(\n|\r\n|\n\r)(aspect0\s+[0-9.:]+)
replace string: $1$2$3$4
and then use the "Capture search":
Thanks for your help. Yes, wanted to preserve just the following in the final ini, removing everything else and it seems a quite complicated challenge indeed... ;)
#
# OSD PER-WINDOW VIDEO OPTIONS
#
aspect0 17:10
Tried your search above but I got no match at all using https://paste.sh/3vzEJkJH#_IZHMlAsw7RUu8esOdmURU5g , even when selecting "Capture search": ATM, the best solution I've found is on https://stackoverflow.com/questions/75212474/keep-only-a-few-specific-lines-inside-some-text-files-using-regex-for-mass-text , which is almost perfect but probably a bit incorrect.
closing this issue, because I can't start helping with regex search strings. I'm coding the tool, not supporting users with their searches, sorry.
I understand, and thanks for helping anyway.
Thinking about this bug... going back to the 1st message (and ignoring the attempt to find a better pattern-matching...) the problem was that test dialogue shows inaccurate results: processed file doesn't look like test dialogue even if I use just "\x0a" removing the \r\n thing... 🤔 Can the line ending problem you mentioned be fixed to make dialogue show the exact result? This means the test window can be misleading and inaccurate...
To show in the test dialogue the correct preview (= matches actual file after Replace) I have to use \r in front of the string:
\r(\n)^(?!.*(\# OSD PER-WINDOW))(?!aspect0).*$
This will remove the CR lines too from preview, as the replacement regex string without \r does on the real file:
(\n)^(?!.*(\# OSD PER-WINDOW))(?!aspect0).*$
This is the text I used for testing in the test panel: https://hastebin.com/uracacaxik.apache Search string:
(\r\n)^(?!.*(\# OSD PER-WINDOW))(?!aspect0).*$
The resulting file (upper-left open in CudaText) shows something different from what was shown in the preview (test panel).