Search found 2302 matches

by dbenham
05 Feb 2020 09:31
Forum: DOS Batch Forum
Topic: Batch script to exctract everything between 2 regex
Replies: 10
Views: 574

Re: Batch script to exctract everything between 2 regex

Sorry, I forgot the /f option, and I also had a case problem. I've updated the code in my prior post. All quotes are needed as written. The outer double quotes are needed to treat the entire construct as a single parameter. The single quotes signify that the string is to be treated as a string literal
by dbenham
04 Feb 2020 14:54
Forum: DOS Batch Forum
Topic: Batch script to exctract everything between 2 regex
Replies: 10
Views: 574

Re: Batch script to exctract everything between 2 regex

You say regex, but it looks like you are looking to match a string literal. I'll run with what you have given. for %%F in (*.txt) do call jrepl "^" "" /k 0 /inc "'Line 2'be+1:'Line 5'be-1" /f "%%F" /o "%%~nF.mod.txt" The /INC option specifies which lines to include in the search. It starts with the ...
by dbenham
04 Feb 2020 14:37
Forum: DOS Batch Forum
Topic: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect
Replies: 28
Views: 1180

Re: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect

I found a very interesting case of token dropping that involves a single redirection without any escape character or line continuation. It only occurs on the last line of a batch script if the line is not terminated with a linefeed. @echo off setlocal prompt $G echo on echo Hello >con world_No_line_...
by dbenham
04 Feb 2020 11:14
Forum: DOS Batch Forum
Topic: Batch script to exctract everything between 2 regex
Replies: 10
Views: 574

Re: Batch script to exctract everything between 2 regex

You have not given enough information to give any help. What are the text markers that identify the text to keep? Are they string literals? or regex? Should the markers be included in the output? Do the markers constitute an entire line? If not then the line containing the markers may need to be spl...
by dbenham
03 Feb 2020 22:38
Forum: DOS Batch Forum
Topic: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect
Replies: 28
Views: 1180

Re: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect

You could also drop tokens if you escape a leading redirection: ^<skipped nul echo OK. Ooooh, that is interesting. It is interesting that ECHO ^<NUL HELLO fully escapes the redirection (it becomes a literal), but ^<NUL ECHO HELLO does not. The only difference of course is the latter occurs before t...
by dbenham
03 Feb 2020 17:04
Forum: DOS Batch Forum
Topic: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect
Replies: 28
Views: 1180

Re: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect

Yep - the "well documented" non-standard wildcards :wink:

You have to be careful with that "<xxxxx" construct 'cause you never know what you might get. :evil:
by dbenham
02 Feb 2020 22:52
Forum: DOS Batch Forum
Topic: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect
Replies: 28
Views: 1180

Re: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect

I don't see any real difference between the single line vs multi-line forms of this destination dropping. @echo off setlocal prompt $G echo on echo #1 >con ^<dropped nul abc echo #2 >con ^ <dropped nul abc --OUTPUT-- >echo #1 abc 123 1>con 0<nul #1 abc 123 >echo #2 abc 123 1>con 0<nul #2 abc 123 Nei...
by dbenham
02 Feb 2020 16:47
Forum: DOS Batch Forum
Topic: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect
Replies: 28
Views: 1180

Re: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect

I think you missed the point I was trying to make. I didn't mean to imply that you cannot have 3 redirections if the middle one is escaped. My intent was to show what happens when you have 3 redirections without any intervening tokens, as in "<one ^<two <three". Sure the statement fails, but look w...
by dbenham
02 Feb 2020 12:57
Forum: DOS Batch Forum
Topic: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect
Replies: 28
Views: 1180

Re: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect

You triggered the "remove token" mechanism without a newline, I didn't know that this is possible, or at least I forget it :) My test #1 is simply a reformat of one of penpen's tests - who in turn claims he got it from you at viewtopic.php?p=32687#p32687. :lol: Tests #2 and #3 result in a syntax er...
by dbenham
02 Feb 2020 10:14
Forum: DOS Batch Forum
Topic: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect
Replies: 28
Views: 1180

Re: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect

I suspect that the "^<nul cmdToken" part somehow recognizes the redirection "<nul" removing that part from the input buffer(/string) and then the '^'-character doubles the '<'-character, so that "< cmdToken" overwrites the previous result. Interesting theory - a stuttering parser. And plausible giv...
by dbenham
31 Jan 2020 20:20
Forum: DOS Batch Forum
Topic: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect
Replies: 28
Views: 1180

Re: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect

Very interesting. Your discovery about ^ before redirection is definitely important, and unsettling :evil: I've also done a bunch of tests with some annotation in the code. It will be hard to read unless you copy the code into your own text editor. Some of the tests aren't so much about token droppi...
by dbenham
31 Jan 2020 14:03
Forum: DOS Batch Forum
Topic: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect
Replies: 28
Views: 1180

Re: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect

Trouble maker :!: Why do you insist on shooting down a perfectly good theory with facts :?: :lol: Actually, that is an interesting find. This redirection parser is certainly a complicated beast. I think I have a basic understanding as to how (sort of why) a single line continued token after redirect...
by dbenham
30 Jan 2020 23:09
Forum: DOS Batch Forum
Topic: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect
Replies: 28
Views: 1180

Re: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect

I've updated my prior post with proposed rules for how CR is handled in phase 2.
by dbenham
30 Jan 2020 16:33
Forum: DOS Batch Forum
Topic: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect
Replies: 28
Views: 1180

Re: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect

Whew. I think I have detailed rules for the redirection parser, disregarding Carriage Returns. I've since updated this post to show proposed rules for how CR behaves in phase 2, especially as it relates to redirection detection. Phase 1.5 is now null and void. Instead, each Carriage Return (CR) is i...
by dbenham
30 Jan 2020 12:11
Forum: DOS Batch Forum
Topic: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect
Replies: 28
Views: 1180

Re: Bug/Mystery in the phase parsing rules 1.5 and 2 CR vs redirect

OMG :shock:

So the parsing rules for redirection need to be established before we can ever hope to figure out what is going on with CR.

Right now it looks like complete chaos.