FindRepl.bat:New regex utility to search and replace strings

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: FindRepl.bat:New regex utility to search and replace strings

#106 Post by foxidrive » 26 Jul 2016 21:56

rem - Nov/30/2014: Version 2.1 - Changed /ARG# by /VAR. Replacements on numbered-blocks of lines.


Code: Select all

d:\test>for /L %a in (1,1,10) do @call z-more
d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied


ccc

ccc

d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied

d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied

d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied

d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied


d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied


d:\test\findrepl.bat(306, 1) Microsoft JScript runtime error: Input past end of file


d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied



Code: Select all

d:\test>for /L %a in (1,1,10) do @call z
d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied

d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied

d:\test\findrepl.bat(528, 4) Microsoft JScript runtime error: Input past end of file

d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied

d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied

d:\test\findrepl.bat(528, 4) Microsoft JScript runtime error: Input past end of file

d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied

d:\test\findrepl.bat(528, 4) Microsoft JScript runtime error: Input past end of file

d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied

d:\test\findrepl.bat(528, 4) Microsoft JScript runtime error: Input past end of file

d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied

d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied

d:\test\findrepl.bat(302, 1) Microsoft JScript runtime error: Permission denied

d:\test\findrepl.bat(528, 4) Microsoft JScript runtime error: Input past end of file

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: FindRepl.bat:New regex utility to search and replace strings

#107 Post by foxidrive » 26 Jul 2016 22:00

dbenham wrote:I can't reproduce your problem - Both work just fine for me after repeated runs ('though I ran the command from the command line, not a script)


Dave Benham


Hmmm. What version of findrepl did you test this with Dave?

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: FindRepl.bat:New regex utility to search and replace strings

#108 Post by thefeduke » 27 Jul 2016 04:30

More interesting observations for foxi: This time on a 64-bit Win 8.1 based temporary Win 10 system. At first I got no errors, so I increased the iterations to 44 and got one and then again about four. I also noticed a significant delay after the last output before returning to prompt. Anyway, here's a test tweak to z-more.bat:

Code: Select all

@echo off
>nul (echo aaa|findrepl1 "aaa" "bbb"|more|findrepl2 "bbb" "ccc")
I eliminated viewing the regular output at some risk to timing and satisfied my curiosity by making copies of findrepl.bat with different names. So here is some output:

Code: Select all

C:\Users\John\scripts>for /L %a in (1,1,99) do @(call z-more "%a" nul)
C:\Users\John\scripts\Routines\FindREPL.bat(318, 1) Microsoft JScript runtime error: Permission denie                             d

C:\Users\John\scripts\Routines\FindREPL.bat(318, 1) Microsoft JScript runtime error: Permission denie                             d

C:\Users\John\scripts\Routines\FindREPL.bat(318, 1) Microsoft JScript runtime error: Permission denie                             d


C:\Users\John\scripts>for /L %a in (1,1,99) do @call z-more
C:\Users\John\scripts\Routines\FindREPL1.bat(318, 1) Microsoft JScript runtime error: Permission deni                             ed


C:\Users\John\scripts>for /L %a in (1,1,99) do @call z-more
C:\Users\John\scripts\Routines\FindREPL1.bat(318, 1) Microsoft JScript runtime error: Permission deni                             ed

C:\Users\John\scripts\Routines\FindREPL1.bat(318, 1) Microsoft JScript runtime error: Permission deni                             ed

The process tried to write to a nonexistent pipe.
C:\Users\John\scripts\Routines\FindREPL2.bat(318, 1) Microsoft JScript runtime error: Permission deni                             ed

C:\Users\John\scripts\Routines\FindREPL2.bat(318, 1) Microsoft JScript runtime error: Permission deni                             ed


C:\Users\John\scripts>2>z-more.txt (for /L %a in (1,1,99) do @call z-more)

C:\Users\John\scripts>2>>z-more.txt (for /L %a in (1,1,99) do @call z-more)
Working with 99 iterations now. There's a new nonexistent pipe message and I was surprised to see failures on both sides of the MORE pipe. The last two series redirected to a log file and here are the contents:

Code: Select all

C:\Users\John\scripts\Routines\FindREPL2.bat(318, 1) Microsoft JScript runtime error: Permission denied

============= end run 1
C:\Users\John\scripts\Routines\FindREPL2.bat(318, 1) Microsoft JScript runtime error: Permission denied

C:\Users\John\scripts\Routines\FindREPL2.bat(318, 1) Microsoft JScript runtime error: Permission denied

C:\Users\John\scripts\Routines\FindREPL1.bat(318, 1) Microsoft JScript runtime error: Permission denied

That is as far as I went and I did not play with z.bat.
John A.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: FindRepl.bat:New regex utility to search and replace strings

#109 Post by foxidrive » 27 Jul 2016 04:58

Thanks John.

This creates findrepl v2 and it worked well here.
It seems to be related to the version.

Code: Select all

@echo off
if not exist "findrepl.bat" (
echo creating "findrepl.bat"
(
echo QGlmIChAQ29kZVNlY3Rpb24gPT0gQEJhdGNoKSBAdGhlbg0KDQo6OiBUaGUgZmly
echo c3QgbGluZSBhYm92ZSBpcy4uLg0KOjogLSBpbiBCYXRjaDogYSB2YWxpZCBJRiBj
echo b21tYW5kIHRoYXQgZG9lcyBub3RoaW5nLg0KOjogLSBpbiBKU2NyaXB0OiBhIGNv
echo bmRpdGlvbmFsIGNvbXBpbGF0aW9uIElGIHN0YXRlbWVudCB0aGF0IGlzIGZhbHNl
echo LA0KOjogICAgICAgICAgICAgICBzbyB0aGlzIEJhdGNoIHNlY3Rpb24gaXMgb21p
echo dHRlZCB1bnRpbCBuZXh0ICJhdC1zaWduIGVuZCIuDQoNCg0KQGVjaG8gb2ZmDQoN
echo CnJlbSB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echo bGluZS4gICAgICAgIGFuZCBFIHRvIHJFbmRCbGsgbGluZS4NCg0KLi4uIGFuZCBv
echo bmUgd2F5IG1vcmUgaWYgclNlYXJjaCBpcyBub3QgZ2l2ZW46ICAgL086czplICAg
echo RnJvbSBsaW5lIFMgdG8gbGluZSBFLg0KSWYgUyBvciBFIGlzIG5lZ2F0aXZlLCBz
echo cGVjaWZ5IGEgYmFja3dhcmRzIGxpbmUgZnJvbSB0aGUgZW5kIG9mIGZpbGUuDQpJ
echo ZiBFIGlzIG5vdCBnaXZlbiwgdGhlbiBpdCBkZWZhdWx0cyB0byB0aGUgbGFzdCBs
echo aW5lIG9mIHRoZSBmaWxlIChzYW1lIGFzIC0xKS4NCg0KVGhlIG91dHB1dCB2YXJ5
echo IGRlcGVuZGluZyBvbiB0aGUgZ2l2ZW4gcGFyYW1ldGVycyBhbmQgc3dpdGNoZXMg
echo dGhpcyB3YXk6DQoNCnJTZWFyY2ggICAgICAgIC9WICAgICAgICAgICAgICAgICBC
echo bG9jayAgICAgICAgICAgIC9COnJCbG9jayAgICAgICAgLyQ6MToyLi4uDQotLS0t
echo LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
echo LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tDQpNYXRjaGVkICAgICAgICBOb24t
echo bWF0Y2hlZCAgICAgICAgQmxvY2tzIG9mICAgICAgICBTZWFyY2ggL0I6ICAgICAg
echo IFNhdmVkDQpsaW5lcy4gICAgICAgICBsaW5lcy4gICAgICAgICAgICAgbGluZXMu
echo ICAgICAgICAgICBpbiBibG9ja3MgICAgICAgIHN1Ym1hdGNoZXMuDQoNCnNSZXBs
echo YWNlICAgICAgIC9SICAgICAgICAgICAgICAgICBCbG9jayAgICAgICAgICAgIC9C
echo OnJCbG9jaw0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
echo LS0tLS0tLS0t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RvcGljLnBocFxRZj0zJnQ9NDY5NyINCiAgICAgICAgICAgICJodHRwOi8vd3d3
echo LmRvc3RpcHMuY29tL2ZvcnVtL3ZpZXd0b3BpYy5waHBcUWY9MyZ0PTQ2OTcmcD0z
echo ODEyMSNwMzgxMjEiDQogICAgICAgICAgICAiaHR0cDovL21zZG4ubWljcm9zb2Z0
echo LmNvbS9lbi11cy9saWJyYXJ5LzZ3emFkMmIyKHY9dnMuODQpLmFzcHgiDQogICAg
echo ICAgICAgICAiaHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5
echo L2tzdGt6NzcxKHY9dnMuODQpLmFzcHgiDQogICAgICAgICAgICAiaHR0cDovL21z
echo ZG4ubWljcm9zb2Z0LmNvbS9lbi11cy9saWJyYXJ5L2NlNTdrOGQ1KHY9dnMuODQp
echo LmFzcHgiDQogICAgICAgICAgICAiaHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9l
echo bi11cy9saWJyYXJ5L2h0Ync0eXdkKHY9dnMuODQpLmFzcHgiKSBkbyAoDQogICBz
echo ZXQgImNob2ljZXM9IWNob2ljZXMhIW4hIg0KICAgc2V0ICJvcHRpb25bIW4hXT0l
echo JX5hIg0KICAgc2V0IC9BIG4rPTENCikNCg0KOmdldE9wdGlvbg0KZWNoby8NCmNo
echo b2ljZSAvQyAlY2hvaWNlcyUwIC9OIC9NICJTZWxlY3Qgb25lIG9mIHByZXZpb3Vz
echo IGhlbHAgdG9waWNzOiINCmlmIGVycm9ybGV2ZWwgJW4lIGdvdG8gOkVPRg0Kc2V0
echo ICJjaG9pY2U9JWVycm9ybGV2ZWwlIg0KZXhwbG9yZXIgIiFvcHRpb25bJWNob2lj
echo ZSVdOlxRPT8hIg0KZWNobyAgLSBIZWxwIG9uIHRvcGljICVjaG9pY2UlIG9wZW5l
echo ZC4uLg0KZ290byBnZXRPcHRpb24NCg0KRW5kIG9mIEJhdGNoIHNlY3Rpb24NCg0K
echo DQpAZW5kDQo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aW9ucy5FeGlzdHMoIlIiKSwNCiAgICBhbHRlcm5hdGlvbiAg
echo PSBvcHRpb25zLkV4aXN0cygiQSIpLA0KICAgIHJlcGxhY2UgICAgICA9IHVuZGVm
echo aW5lZCwNCiAgICBxdW90ZSAgICAgICAgPSBvcHRpb25zLkl0ZW0oIlEiKSwNCiAg
echo ICBKZXhwciAgICAgICAgPSBvcHRpb25zLkV4aXN0cygiSiIpLA0KDQogICAgbGlu
echo ZU51bWJlciA9IDAsIHJhbmdlID0gbmV3IEFycmF5KCksDQogICAgcHJvY0xpbmVz
echo ID0gZmFsc2UsIHByb2NCbG9ja3MgPSBmYWxzZSwNCiAgICBuZXh0TWF0Y2gsIHJl
echo c3VsdCAgPSAwLA0KDQogICAgbWF0Y2ggPSBmdW5jdGlvbiAoIGxpbmUsIHJlZ2V4
echo ICkgeyByZXR1cm4gbGluZS5zZWFyY2gocmVnZXgpID49IDA7IH0sDQoNCiAgICBw
echo YXJzZUludHMgPQ0KICAgICAgIGZ1bmN0aW9uICggc3RycyApIHsNCiAgICAgICAg
echo ICB2YXIgSW50cyA9IG5ldyBBcnJheSgpOw0KICAgICAgICAgIGZvciAoIHZhciBp
echo ID0gMDsgaSA8IHN0cnMubGVuZ3RoOyArK2kgKSB7DQogICAgICAgICAgICAgSW50
echo c1tpXSA9IHBhcnNlSW50KHN0cnNbaV0pOw0KICAgICAgICAgIH0NCiAgICAgICAg
echo ICByZXR1cm4gSW50czsNCiAgICAgICB9LA0KDQogICAgZ2V0UmVnRXhwID0NCiAg
echo ICAgICBmdW5jdGlvbiAoIHBhcmFtLCBqdXN0TG9hZCApIHsNCiAgICAgICAgICB2
echo YXIgcmVzdWx0ID0gcGFyYW07DQogICAgICAgICAgaWYgKCByZXN1bHQuc3Vic3Ry
echo KDAsMSkgPT0gIj0iICkgew0KICAgICAgICAgICAgIHJlc3VsdCA9IGVudihyZXN1
echo bHQuc3Vic3RyKDEpKTsNCiAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAg
echo IGlmICggcXVvdGUgIT0gdW5kZWZpbmVkICkgcmVzdWx0ID0gcmVzdWx0LnJlcGxh
echo Y2UoZXZhbCgiLyIrcXVvdGUrIi9nIiksJyInKTsNCiAgICAgICAgICB9DQogICAg
echo ICAgICAgaWYgKCAhIGp1c3RMb2FkICkgcmVzdWx0ID0gbmV3IFJlZ0V4cChyZXN1
echo bHQsImdtIitpZ25vcmVDYXNlKTsNCiAgICAgICAgICByZXR1cm4gcmVzdWx0Ow0K
echo ICAgICAgIH0NCiAgICA7IC8vIGVuZCB2YXINCg0KLy8gUHJlZGVmaW5lZCB2YXJp
echo YWJsZXMNCg0KZm9yICggdmFyIGkgPSAxOyBibG9jaz1vcHRpb25zLkl0ZW0oIkFS
echo RyIraSk7IGkrKyApIHsNCiAgIGlmICggYmxvY2suc3Vic3RyKDAsMSkgPT0gIj0i
echo ICkgYmxvY2sgPSBlbnYoYmxvY2suc3Vic3RyKDEpKTsNCiAgIGV2YWwgKCAndmFy
echo IEFSRycraSsnPSInK2Jsb2NrKyciOycgKTsNCn0NCnZhciBkYXlzTm93ID0gTWF0
echo aC5mbG9vcigobmV3IERhdGUoKSkuZ2V0VGltZSgpLzg2NDAwMDAwKSwgbiA9IDA7
echo DQppZiAoIEpleHByKSB7DQogICB2YXIgSmV4cHJOID0gMTA7DQogICBpZiAoIG9w
echo dGlvbnMuSXRlbSgiSiIpICkgSmV4cHJOID0gcGFyc2VJbnQob3B0aW9ucy5JdGVt
echo KCJKIikpOw0KICAgZm9yICggdmFyIGkgPSAxOyBpIDw9IEpleHByTjsgaSsrICkg
echo ZXZhbCggInZhciBTVU0iK2krIj0wLE4iK2krIj0wLFBST0QiK2krIj0xOyIgKTsN
echo Cn0NCg0KLy8gUHJlZGVmaW5lZCBmdW5jdGlvbnMNCg0KZnVuY3Rpb24gY2hvb3Nl
echo KGFyZyxpKXtyZXR1cm4oYXJnW2ldKTt9Ow0KZnVuY3Rpb24gbWF4KGFyZyxhLGIp
echo e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echo UmVwbGFjZSAiJytzKyciIGJ5OiAnKTsgcmV0dXJuKGZpbGUuUmVhZExpbmUoKSk7
echo fTsNCg0KaWYgKCBmaWxlID0gb3B0aW9ucy5JdGVtKCJHIikgKSB7DQogICBmaWxl
echo ID0gZnNvLk9wZW5UZXh0RmlsZShmaWxlLCAxKTsNCiAgIHNlYXJjaCA9ICIiOw0K
echo ICAgaWYgKCBhbHRlcm5hdGlvbiApIHJlcGxhY2UgPSAiIjsNCiAgIHZhciBzZXBJ
echo biA9IChKZXhwcj8nfHwnOid8JyksIHNlcE91dCA9ICIiOw0KICAgd2hpbGUgKCAh
echo IGZpbGUuQXRFbmRPZlN0cmVhbSApIHsNCiAgICAgIGJsb2NrID0gZmlsZS5SZWFk
echo TGluZSgpLnNwbGl0KHNlcEluKTsNCiAgICAgIHNlYXJjaCArPSBzZXBPdXQrYmxv
echo Y2tbMF07DQogICAgICBpZiAoIGFsdGVybmF0aW9uICkgcmVwbGFjZSArPSBzZXBP
echo dXQrYmxvY2tbMV07DQogICAgICBzZXBPdXQgPSBzZXBJbjsNCiAgIH0NCiAgIGJs
echo b2NrID0gdW5kZWZpbmVkOw0KICAgZmlsZS5DbG9zZSgpOw0KfSBlbHNlIHsgIC8v
echo IE5vIG9wdGlvbiAvRyBnaXZlbg0KICAgaWYgKCBhcmdzLmxlbmd0aCA+IDAgKSB7
echo DQogICAgICBzZWFyY2ggPSBnZXRSZWdFeHAoYXJncy5JdGVtKDApLHRydWUpOw0K
echo ICAgfQ0KICAgaWYgKCBhcmdzLmxlbmd0aCA+IDEgKSB7DQogICAgICByZXBsYWNl
echo ID0gYXJncy5JdGVtKDEpOw0KICAgICAgaWYgKCByZXBsYWNlLnN1YnN0cigwLDEp
echo ID09ICI9IiApIHJlcGxhY2UgPSBlbnYocmVwbGFjZS5zdWJzdHIoMSkpOw0KICAg
echo fQ0KfQ0KaWYgKCByZXBsYWNlICkgeyAgLy8gQ2hlY2sgdGhpcyEgSXQgbWF5IGNh
echo dX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IEpleHByICkgeyAgLy8gT3JpZ2luYWwgdmVyc2lvbg0KDQogICAgICAgICB2
echo YXIgc2VhcmNoQSA9IHNlYXJjaC5zcGxpdCgifCIpLA0KICAgICAgICAgICAgIHJl
echo cGxhY2VBID0gcmVwbGFjZS5zcGxpdCgifCIpLA0KICAgICAgICAgICAgIHJlcGwg
echo PSBuZXcgQXJyYXkoKTsNCiAgICAgICAgIGZvciAoIHZhciBpID0gMDsgaSA8IHNl
echo YXJjaEEubGVuZ3RoOyBpKysgKSB7DQogICAgICAgICAgICByZXBsW3NlYXJjaEFb
echo aV1dID0gcmVwbGFjZUFbaV07DQogICAgICAgICB9DQogICAgICAgICByZXBsYWNl
echo ID0gZnVuY3Rpb24oJDAsJDEsJDIpIHsgcmV0dXJuIHJlcGxbJDBdOyB9Ow0KICAg
echo ICAgICAgc2VhcmNoQS5sZW5ndGggPSAwOw0KICAgICAgICAgcmVwbGFjZUEubGVu
echo Z3RoID0gMDsNCg0KICAgICAgfSBlbHNlIHsgIC8vIFZlcnNpb24gMjogU2VhcmNo
echo IGFsdGVybmF0aW9uIGhhdmUgcmVndWxhciBleHByZXNzaW9uczogICJyZWdleHAx
echo fHxyZWdleHAyfHxyZWdleHAzIg0KICAgICAgICAgICAgICAgIC8vICAgICAgICAg
echo ICAgUmVwbGFjZSBhbHRlcm5hdGlvbiBoYXZlIEpTY3JpcHQgZXhwcmVzc2lvbnM6
echo ICInUmUnfHwncGxhJ3x8J2NlJyINCg0KICAgICAgICAgSmV4cHIgPSBmYWxzZTsN
echo Cg0KICAgICAgICAgdmFyIHNlYXJjaEEgPSBzZWFyY2guc3BsaXQoInx8IiksICAg
echo ICAgLy8gZGl2aWRlIHNlYXJjaCAicmVnZXhwMXx8cmVnZXhwMnx8cmVnZXhwMyIg
echo aW4gcGFydHMNCiAgICAgICAgICAgICByZXBsID0gcmVwbGFjZS5zcGxpdCgifHwi
echo KTsgICAgICAvLyB0aGUgc2FtZSBmb3IgInJlcGxhY2UxfHxyZXBsYWNlMnx8cmVw
echo bGFjZTMiDQogICAgICAgICBzZWFyY2ggPSAiIjsNCiAgICAgICAgIHJlcGxhY2Ug
echo PSAiJDAsIjsNCiAgICAgICAgIGZvciAoIHZhciBpID0gMDsgaSA8IHNlYXJjaEEu
echo bGVuZ3RoOyBpKysgKSB7ICAgLy8gcHJvY2VzcyBlYWNoIHJlZ2V4cEkNCiAgICAg
echo ICAgICAgIHNlYXJjaCArPSAoaT8nfCc6JycpKycoJytzZWFyY2hBW2ldKycpJzsg
echo ICAvLyByZS1hc3NlbWJsZSBzZWFyY2ggcmVnZXhwIGFzICIocmVnZXhwMSl8KHJl
echo Z2V4cDIpfChyZWd4ZXAzKSINCiAgICAgICAgICAgIHZhciBzdWJleHBycyA9IHNl
echo YXJjaEFbaV0ubWF0Y2goL1teXFxdP1woL2cpOy8vIGNvdW50IHN1YmV4cHJlc3Np
echo b25zIGluIHRoaXMgcmVnZXhwSQ0KICAgICAgICAgICAgc3ViZXhwcnMgPSBzdWJl
echo eHBycz9zdWJleHBycy5sZW5ndGg6MDsgICAvLyB6ZXJvIGlmIG5vIG9uZQ0KICAg
echo ICAgICAgICAgZm9yICggdmFyIGogPSAwOyBqIDw9IHN1YmV4cHJzOyBqKysgKSB7
echo ICAgLy8gaW5zZXJ0IGVhY2ggc3ViZXhwcmVzc2lvbg0KICAgICAgICAgICAgICAg
echo ICAgcmVwbGFjZSArPSAnJCcrKGkrMSkrJyQnK2orJywnOyAgIC8vICdmdW5jdGlv
echo bigkMCwnICsgIiRpJDAsJGkkaiwuLi4iDQogICAgICAgICAgICB9DQogICAgICAg
echo ICAgICByZXBsW2ldID0gcmVwbFtpXS5yZXBsYWNlKC9cJChcZHsxLDJ9KS9nLCIk
echo JCIrKGkrMSkrIiQkJDEiKTsgICAvLyBjaGFuZ2UgIiRuIiBieSAiJGkkbiIgaW4g
echo cmVwbGFjZUkNCiAgICAgICAgIH0NCg0KICAgICAgICAgcmVwbGFjZSArPSAiJG9m
echo ZnNldCwkc3RyaW5nIjsgICAgICAgICAgICAgLy8gJ2Z1bmN0aW9uKCQwLCAkaSQw
echo LCRpJDEsJGkkMiwgLi4uJyArICIkb2Zmc2V0LCAkc3RyaW5nKSINCiAgICAgICAg
echo IGV2YWwgKCAicmVwbGFjZSA9IGZ1bmN0aW9uKCIrcmVwbGFjZSsiKSB7IGZvciAo
echo dmFyIGk9MTsgIWV2YWwoJyQnK2krJyQwJyk7IGkrKyk7IHJldHVybihldmFsKHJl
echo cGxbaS0xXSkpOyB9OyIgKTsNCiAgICAgICAgIHNlYXJjaEEgPSB1bmRlZmluZWQ7
echo DQogICAgICAgICBpZiAoIHN1YmV4cHJzICkgc3ViZXhwcnMgPSB1bmRlZmluZWQ7
echo DQoNCiAgICAgIH0NCg0KICAgfSBlbHNlIHsgIC8vIE5vIGFsdGVybmF0aW9uDQoN
echo CiAgICAgIHZhciBldmFsUmVwbGFjZSA9ICIiOw0KICAgICAgaWYgKCBKZXhwcikg
echo ew0KICAgICAgICAgZm9yICggdmFyIGkgPSAwOyBpIDw9IEpleHByTjsgaSsrICkg
echo ZXZhbFJlcGxhY2UgKz0gKGk/JywnOicnKSsnJCcraTsNCiAgICAgICAgIGV2YWwg
echo KCAiZXZhbFJlcGxhY2UgPSBmdW5jdGlvbigiK2V2YWxSZXBsYWNlKyIpIHsgcmV0
echo dXJuKGV2YWwocmVwbGFjZSkpOyB9OyIgKTsNCiAgICAgIH0NCg0KICAgfQ0KDQp9
echo IGVsc2UgeyAgLy8gcmVwbGFjZSA9PSB1bmRlZmluZWQ6IEZpbmQtb25seSBvcGVy
echo YXRpb24gKHRvIGRvOiBhZGp1c3QgdmFsdWVzIG9mIC8kIHN3aXRjaCkNCg0KICAg
echo aWYgKCBKZXhwciApIHsgIC8vIEZpbmQgYSAic2Vjb25kLWxldmVsIiBhbHRlcm5h
echo dGlvbg0KICAgICAgdmFyIHNlYXJjaEEgPSBzZWFyY2guc3BsaXQoInx8Iik7ICAg
echo ICAgICAgLy8gZGl2aWRlIHNlYXJjaCAicmVnZXhwMXx8cmVnZXhwMnx8cmVnZXhw
echo MyIgaW4gcGFydHMNCiAgICAgIHNlYXJjaCA9ICIiOw0KICAgICAgZm9yICggdmFy
echo IGkgPSAwOyBpIDwgc2VhcmNoQS5sZW5ndGg7IGkrKyApIHsNCiAgICAgICAgIHNl
echo YXJjaCArPSAoaT8nfCc6JycpKycoJytzZWFyY2hBW2ldKycpJzsgICAvLyByZS1h
echo c3NlbWJsZSBzZWFyY2ggcmVnZXhwIGFzICIocmVnZXhwMSl8KHJlZ2V4cDIpfChy
echo ZWd4ZXAzKSINCiAgICAgIH0NCiAgICAgIHNlYXJjaEEgPSB1bmRlZmluZWQ7DQog
echo ICB9DQoNCn0NCg0KaWYgKCBzZWFyY2ggIT0gdW5kZWZpbmVkICkgc2VhcmNoID0g
echo bmV3IFJlZ0V4cChzZWFyY2gsICJnbSIraWdub3JlQ2FzZSk7DQppZiAoIGJsb2Nr
echo ICAhPSB1bmRlZmluZWQgKSBibG9jayAgPSBuZXcgUmVnRXhwKGJsb2NrICwgImdt
echo IitpZ25vcmVDYXNlKTsNCmZpbGUgPSBmc28uT3BlblRleHRGaWxlKCJDT05JTiQi
echo LCAxKTsNCg0KDQovLyBQUk9DRVNTIElOUFVUIEZJTEUNCg0KDQovLyBGSU5EUkVQ
echo TCBbL0ldIFsvVl0gWy9OXSByU2VhcmNoIFsvRTpyRW5kQmxrXSBbL086czplXSBb
echo L0I6ckJsb2NrXSBbLyQ6czEuLi5dDQovLyAgICAgICAgICBbWy9SXSBbL0FdIHNS
echo ZXBsYWNlXSBbL1E6Y10gWy9TOnNTb3VyY2VdDQoNCi8vICAgICAgICAgIEluIFNl
echo YXJjaCBhbmQgUmVwbGFjZSBvcGVyYXRpb25zOg0KLy8gICAgICAgICAgICAvViBv
echo ciAvTiBzd2l0Y2hlcyBpbXBsaWVzIGxpbmUgcHJvY2Vzc2luZw0KLy8gICAgICAg
echo ICAgICAvRSBvciAvTyBzd2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hciBsYXN0Qnl0ZSA9IGZpbGVDb250ZW50cy5zbGljZSgt
echo MSk7DQogICAgICBmaWxlQ29udGVudHMgPSBmaWxlQ29udGVudHMucmVwbGFjZSgv
echo KFteXHJcbl0qKVxyP1xuL2csIiQxXG4iKS5tYXRjaCgvXi4qJC9nbSk7DQogICAg
echo ICBsYXN0TGluZSA9IGZpbGVDb250ZW50cy5sZW5ndGggLSAoKGxhc3RCeXRlID09
echo ICJcbiIpPzE6MCk7DQogICB9DQoNCiAgIGlmICggcHJvY0Jsb2NrcyApIHsgIC8v
echo IENyZWF0ZSBibG9ja3Mgb2YgbGluZXMNCiAgICAgIGlmICggc2VhcmNoICE9IHVu
echo ZGVmaW5lZCApIHsgIC8vIEJsb2NrcyBiYXNlZCBvbiBTZWFyY2ggbGluZXM6DQog
echo ICAgICAgICBpZiAoIG9mZnNldCA9PSB1bmRlZmluZWQgKSBvZmZzZXQgPSBuZXcg
echo QXJyYXkoMCwwKTsNCiAgICAgICAgIGZvciAoIHZhciBpID0gMTsgaSA8PSBsYXN0
echo TGluZTsgaSsrICkgew0KICAgICAgICAgICAgaWYgKCBtYXRjaChmaWxlQ29udGVu
echo dHNbaS0xXSxzZWFyY2gpICkgew0KICAgICAgICAgICAgICAgaWYgKCBlbmRCbGsg
echo IT0gdW5kZWZpbmVkICkgeyAgLy8gMS0gZnJvbSBTZWFyY2ggbGluZSB0byBFbmRC
echo bGsgbGluZSBbK29mZnNldHNdLg0KICAgICAgICAgICAgICAgICAgZm9yICggdmFy
echo IGo9aSsxOyBqPD1sYXN0TGluZSAmJiAhbWF0Y2goZmlsZUNvbnRlbnRzW2otMV0s
echo ZW5kQmxrKTsgaisrICk7DQogICAgICAgICAgICAgICAgICBpZiAoIGogPD0gbGFz
echo dExpbmUgKSB7DQogICAgICAgICAgICAgICAgICAgICB2YXIgcyA9IGkrb2Zmc2V0
echo WzBdLCBlID0gaitvZmZzZXRbMV07DQogICAgICAgICAgICAgICAgICAgICAvLyBJ
echo bnNlcnQgYWRkaXRpb25hbCBjb2RlIGhlcmUgdG8gY2FuY2VsIG92ZXJsYXBwZWQg
echo YmxvY2tzDQogICAgICAgICAgICAgICAgICAgICByYW5nZS5wdXNoKHM+MD9zOjEs
echo IGU+MD9lOjEpOw0KICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAg
echo ICAgaSA9IGo7DQogICAgICAgICAgICAgICB9IGVsc2UgeyAgLy8gMi0gc3Vycm91
echo bmRpbmcgU2VhcmNoIGxpbmVzIHdpdGggb2Zmc2V0cy4NCiAgICAgICAgICAgICAg
echo ICAgIHMgPSBpK29mZnNldFswXSwgZSA9IGkrb2Zmc2V0WzFdOw0KICAgICAgICAg
echo ICAgICAgICAgcmFuZ2UucHVzaChzPjA/czoxLCBlPjA/ZToxKTsNCiAgICAgICAg
echo ICAgICAgIH0NCiAgICAgICAgICAgIH0NCiAgICAgICAgIH0NCiAgICAgIH0gZWxz
echo ZSB7ICAvLyBPZmZzZXQgd2l0aCBubyBTZWFyY2g6IGJsb2NrIGlzIHJhbmdlIG9m
echo IGxpbmVzDQogICAgICAgICBpZiAoIG9mZnNldC5sZW5ndGggPCAyICkgb2Zmc2V0
echo WzFdID0gbGFzdExpbmU7DQogICAgICAgICBzID0gb2Zmc2V0WzBdPDAgPyBvZmZz
echo ZXRbMF0rbGFzdExpbmUrMSA6IG9mZnNldFswXTsNCiAgICAgICAgIGUgPSBvZmZz
echo ZXRbMV08MCA/IG9mZnNldFsxXStsYXN0TGluZSsxIDogb2Zmc2V0WzFdOw0KICAg
echo ICAgICAgcmFuZ2UucHVzaChzPjA/czoxLCBlPjA/ZToxKTsNCiAgICAgIH0NCiAg
echo ICAgIGlmICggcmFuZ2UubGVuZ3RoID09IDAgKSBXU2NyaXB0LlF1aXQoMCk7DQog
echo ICAgICByYW5nZS5wdXNoKDB4RkZGRkZGRkYsMHhGRkZGRkZGRik7DQogICB9DQoN
echo Cn0NCi8vIGVuZGlmIFByb2Nlc3MgU291cmNlIHN0cmluZyBpbnN0ZWFkIG9mIGZp
echo bGUNCg0KaWYgKCByZXBsYWNlID09IHVuZGVmaW5lZCApIHsgIC8vIFNlYXJjaCBv
echo cGVyYXRpb25zDQogICBpZiAoIHByb2NMaW5lcyApIHsgIC8vIFNlYXJjaCBvbiBs
echo aW5lcw0KICAgICAgaWYgKCBwcm9jQmxvY2tzICkgeyAgLy8gUHJvY2VzcyBwcmV2
echo aW91c2x5IGNyZWF0ZWQgYmxvY2tzDQogICAgICAgICBmb3IgKCB2YXIgcj0wLCBs
echo aW5lTnVtYmVyPTE7IGxpbmVOdW1iZXIgPD0gbGFzdExpbmU7IGxpbmVOdW1iZXIr
echo KyApIHsNCiAgICAgICAgICAgIGlmICggKHJhbmdlW3JdPD1saW5lTnVtYmVyICYm
echo IGxpbmVOdW1iZXI8PXJhbmdlW3IrMV0pICE9IG5vdE1hdGNoZWQgKSB7DQogICAg
echo ICAgICAgICAgICBpZiAoIHN1Ym1hdGNoZXMgIT0gdW5kZWZpbmVkICkgew0KICAg
echo ICAgICAgICAgICAgICAgaWYgKCBzaG93TnVtYmVyICkgV1NjcmlwdC5TdGRvdXQu
echo V3JpdGUobGluZU51bWJlcisiOiIpOw0KICAgICAgICAgICAgICAgICAgd2hpbGUg
echo KCAobmV4dE1hdGNoID0gYmxvY2suZXhlYyhmaWxlQ29udGVudHNbbGluZU51bWJl
echo ci0xXSkpICE9IG51bGwgKSB7DQogICAgICAgICAgICAgICAgICAgICBmb3IgKCB2
echo YXIgcyA9IDA7IHMgPCBzdWJtYXRjaGVzLmxlbmd0aDsgcysrICkgew0KICAgICAg
echo ICAgICAgICAgICAgICAgICAgV1NjcmlwdC5TdGRvdXQuV3JpdGUoIiAiICsgKHF1
echo b3RlIT11bmRlZmluZWQ/cXVvdGU6JyInKSArDQogICAgICAgICAgICAgICAgICAg
echo ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBuZXh0TWF0Y2hbc3VibWF0
echo Y2hlc1tzXV0gKw0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
echo ICAgICAgICAgICAgICAgKHF1b3RlIT11bmRlZmluZWQ/cXVvdGU6JyInKSk7DQog
echo ICAgICAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICAgICByZXN1
echo bHQrKzsNCiAgICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICAgIFdT
echo Y3JpcHQuU3Rkb3V0LldyaXRlTGluZSgpOw0KICAgICAgICAgICAgICAgfSBlbHNl
echo IHsNCiAgICAgICAgICAgICAgICAgIGlmICggYmxvY2sgPT0gdW5kZWZpbmVkICB8
echo fCAgbWF0Y2goZmlsZUNvbnRlbnRzW2xpbmVOdW1iZXItMV0sYmxvY2spICkgew0K
echo ICAgICAgICAgICAgICAgICAgICAgaWYgKCBzaG93TnVtYmVyICkgV1NjcmlwdC5T
echo dGRvdXQuV3JpdGUobGluZU51bWJlcisiOiIpOw0KICAgICAgICAgICAgICAgICAg
echo ICAgV1NjcmlwdC5TdGRvdXQuV3JpdGVMaW5lKGZpbGVDb250ZW50c1tsaW5lTnVt
echo YmVyLTFdKTsNCiAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCsrOw0KICAgICAg
echo ICAgICAgICAgICAgfQ0KICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgfQ0K
echo ICAgICAgICAgICAgaWYgKCBsaW5lTnVtYmVyID49IHJhbmdlW3IrMV0gKSByICs9
echo IDI7DQogICAgICAgICB9DQogICAgICB9IGVsc2UgeyAgLy8gUHJvY2VzcyBhbGwg
echo bGluZXMgZm9yIFNlYXJjaA0KICAgICAgICAgZm9yICggbGluZU51bWJlciA9IDE7
echo IGxpbmVOdW1iZXIgPD0gbGFzdExpbmU7IGxpbmVOdW1iZXIrKyApIHsNCiAgICAg
echo ICAgICAgIGlmICggbWF0Y2goZmlsZUNvbnRlbnRzW2xpbmVOdW1iZXItMV0sc2Vh
echo cmNoKSAhPSBub3RNYXRjaGVkICkgew0KICAgICAgICAgICAgICAgaWYgKCBzaG93
echo TnVtYmVyICkgV1NjcmlwdC5TdGRvdXQuV3JpdGUobGluZU51bWJlcisiOiIpOw0K
echo ICAgICAgICAgICAgICAgaWYgKCBzdWJtYXRjaGVzICE9IHVuZGVmaW5lZCApIHsN
echo CiAgICAgICAgICAgICAgICAgIHNlYXJjaC5sYXN0SW5kZXggPSAwOw0KICAgICAg
echo ICAgICAgICAgICAgd2hpbGUgKCAobmV4dE1hdGNoID0gc2VhcmNoLmV4ZWMoZmls
echo ZUNvbnRlbnRzW2xpbmVOdW1iZXItMV0pKSAhPSBudWxsICkgew0KICAgICAgICAg
echo ICAgICAgICAgICAgZm9yICggdmFyIHMgPSAwOyBzIDwgc3VibWF0Y2hlcy5sZW5n
echo dGg7IHMrKyApIHsNCiAgICAgICAgICAgICAgICAgICAgICAgIFdTY3JpcHQuU3Rk
echo b3V0LldyaXRlKCIgIiArIChxdW90ZSE9dW5kZWZpbmVkP3F1b3RlOiciJykgKw0K
echo ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
echo ICAgbmV4dE1hdGNoW3N1Ym1hdGNoZXNbc11dICsNCiAgICAgICAgICAgICAgICAg
echo ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChxdW90ZSE9dW5kZWZp
echo bmVkP3F1b3RlOiciJykpOw0KICAgICAgICAgICAgICAgICAgICAgfQ0KICAgICAg
echo ICAgICAgICAgICAgICAgcmVzdWx0Kys7DQogICAgICAgICAgICAgICAgICB9DQog
echo ICAgICAgICAgICAgICAgICBXU2NyaXB0LlN0ZG91dC5Xcml0ZUxpbmUoKTsNCiAg
echo ICAgICAgICAgICAgIH0gZWxzZSB7DQogICAgICAgICAgICAgICAgICBXU2NyaXB0
echo LlN0ZG91dC5Xcml0ZUxpbmUoZmlsZUNvbnRlbnRzW2xpbmVOdW1iZXItMV0pOw0K
echo ICAgICAgICAgICAgICAgICAgcmVzdWx0Kys7DQogICAgICAgICAgICAgICB9DQog
echo ICAgICAgICAgICB9DQogICAgICAgICB9DQogICAgICB9DQoNCiAgIH0gZWxzZSB7
echo ICAvLyBTZWFyY2ggb24gZW50aXJlIGZpbGUgYW5kIHNob3cgc3VibWF0Y2hlZCBz
echo dWJzdHJpbmdzDQogICAgICBpZiAoIHN1Ym1hdGNoZXMgIT0gdW5kZWZpbmVkICkg
echo ew0KICAgICAgICAgd2hpbGUgKCAobmV4dE1hdGNoID0gc2VhcmNoLmV4ZWMoZmls
echo ZUNvbnRlbnRzKSkgIT0gbnVsbCApIHsNCiAgICAgICAgICAgIGZvciAoIHZhciBz
echo ID0gMDsgcyA8IHN1Ym1hdGNoZXMubGVuZ3RoOyBzKysgKSB7DQogICAgICAgICAg
echo ICAgICBXU2NyaXB0LlN0ZG91dC5Xcml0ZSgiICIgKyAocXVvdGUhPXVuZGVmaW5l
echo ZD9xdW90ZTonIicpICsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
echo ICAgICAgICAgIG5leHRNYXRjaFtzdWJtYXRjaGVzW3NdXSArDQogICAgICAgICAg
echo ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAocXVvdGUhPXVuZGVmaW5l
echo ZD9xdW90ZTonIicpKTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIHJlc3Vs
echo dCsrOw0KICAgICAgICAgICAgV1NjcmlwdC5TdGRvdXQuV3JpdGVMaW5lKCk7DQog
echo ICAgICAgICB9DQogICAgICB9DQogICB9DQoNCn0gZWxzZSB7ICAvLyBSZXBsYWNl
echo IG9wZXJhdGlvbnMNCg0KICAgaWYgKCBwcm9jTGluZXMgKSB7ICAvLyBSZXBsYWNl
echo IG9uIGxpbmVzDQogICAgICBpZiAoIHByb2NCbG9ja3MgKSB7ICAvLyBQcm9jZXNz
echo IHByZXZpb3VzbHkgY3JlYXRlZCBibG9ja3MNCiAgICAgICAgIGlmICggYmxvY2sg
echo PT0gdW5kZWZpbmVkICkgYmxvY2sgPSBzZWFyY2g7ICAvLyBSZXBsYWNlIHJTZWFy
echo Y2ggb3IgckJsb2NrICh0aGUgbGFzdCBvbmUpDQogICAgICAgICB2YXIgQ1JMRnJl
echo bW92ZWQgPSBmYWxzZTsNCiAgICAgICAgIGZvciAoIHZhciByPTAsIGxpbmVOdW1i
echo ZXI9MTsgbGluZU51bWJlciA8PSBsYXN0TGluZTsgbGluZU51bWJlcisrICkgew0K
echo ICAgICAgICAgICAgaWYgKCByYW5nZVtyXTw9bGluZU51bWJlciAmJiBsaW5lTnVt
echo YmVyPD1yYW5nZVtyKzFdICkgew0KICAgICAgICAgICAgICAgaWYgKCByZW1vdmVD
echo UkxGICkgew0KICAgICAgICAgICAgICAgICAgV1NjcmlwdC5TdGRvdXQuV3JpdGUo
echo ZmlsZUNvbnRlbnRzW2xpbmVOdW1iZXItMV0pOw0KICAgICAgICAgICAgICAgICAg
echo Q1JMRnJlbW92ZWQgPSB0cnVlOw0KICAgICAgICAgICAgICAgICAgcmVzdWx0Kys7
echo DQogICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAgaWYg
echo KCBtYXRjaChmaWxlQ29udGVudHNbbGluZU51bWJlci0xXSxibG9jaykgKSB7DQog
echo ICAgICAgICAgICAgICAgICAgICBpZiAoIENSTEZyZW1vdmVkICkgeyBXU2NyaXB0
echo LlN0ZG91dC5Xcml0ZUxpbmUoKTsgQ1JMRnJlbW92ZWQgPSBmYWxzZTsgfQ0KICAg
echo ICAgICAgICAgICAgICAgICAgV1NjcmlwdC5TdGRvdXQuV3JpdGVMaW5lKGZpbGVD
echo b250ZW50c1tsaW5lTnVtYmVyLTFdLnJlcGxhY2UoYmxvY2ssSmV4cHI/ZXZhbFJl
echo cGxhY2U6cmVwbGFjZSkpOw0KICAgICAgICAgICAgICAgICAgICAgcmVzdWx0Kys7
echo DQogICAgICAgICAgICAgICAgICB9IGVsc2Ugew0KICAgICAgICAgICAgICAgICAg
echo ICAgaWYgKCBDUkxGcmVtb3ZlZCApIHsgV1NjcmlwdC5TdGRvdXQuV3JpdGVMaW5l
echo KCk7IENSTEZyZW1vdmVkID0gZmFsc2U7IH0NCiAgICAgICAgICAgICAgICAgICAg
echo IGlmICggISBqdXN0UmVwbGFjZWQgKSBXU2NyaXB0LlN0ZG91dC5Xcml0ZUxpbmUo
echo ZmlsZUNvbnRlbnRzW2xpbmVOdW1iZXItMV0pOw0KICAgICAgICAgICAgICAgICAg
echo fQ0KICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAgfSBlbHNlIHsNCiAgICAg
echo ICAgICAgICAgIGlmICggQ1JMRnJlbW92ZWQgKSB7IFdTY3JpcHQuU3Rkb3V0Lldy
echo aXRlTGluZSgpOyBDUkxGcmVtb3ZlZCA9IGZhbHNlOyB9DQogICAgICAgICAgICAg
echo ICBpZiAoICEganVzdFJlcGxhY2VkICkgV1NjcmlwdC5TdGRvdXQuV3JpdGVMaW5l
echo KGZpbGVDb250ZW50c1tsaW5lTnVtYmVyLTFdKTsNCiAgICAgICAgICAgIH0NCiAg
echo ICAgICAgICAgIGlmICggbGluZU51bWJlciA+PSByYW5nZVtyKzFdICkgciArPSAy
echo Ow0KICAgICAgICAgfQ0KICAgICAgICAgaWYgKCBDUkxGcmVtb3ZlZCApIHsgV1Nj
echo cmlwdC5TdGRvdXQuV3JpdGVMaW5lKCk7IENSTEZyZW1vdmVkID0gZmFsc2U7IH0N
echo CiAgICAgIH0gZWxzZSB7ICAvLyBQcm9jZXNzIGFsbCBsaW5lcyBmb3IgUmVwbGFj
echo ZQ0KICAgICAgICAgZm9yICggbGluZU51bWJlciA9IDE7IGxpbmVOdW1iZXIgPD0g
echo bGFzdExpbmU7IGxpbmVOdW1iZXIrKyApIHsNCiAgICAgICAgICAgIGlmICggbWF0
echo Y2goZmlsZUNvbnRlbnRzW2xpbmVOdW1iZXItMV0sc2VhcmNoKSApIHsNCiAgICAg
echo ICAgICAgICAgIFdTY3JpcHQuU3Rkb3V0LldyaXRlTGluZShmaWxlQ29udGVudHNb
echo bGluZU51bWJlci0xXS5yZXBsYWNlKHNlYXJjaCxKZXhwcj9ldmFsUmVwbGFjZTpy
echo ZXBsYWNlKSk7DQogICAgICAgICAgICAgICByZXN1bHQrKzsNCiAgICAgICAgICAg
echo IH0gZWxzZSB7DQogICAgICAgICAgICAgICBpZiAoICEganVzdFJlcGxhY2VkICkg
echo V1NjcmlwdC5TdGRvdXQuV3JpdGVMaW5lKGZpbGVDb250ZW50c1tsaW5lTnVtYmVy
echo LTFdKTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgIH0NCiAgICAgIH0NCg0KICAg
echo fSBlbHNlIHsgIC8vIFJlcGxhY2Ugb24gZW50aXJlIGZpbGUNCiAgICAgIFdTY3Jp
echo cHQuU3Rkb3V0LldyaXRlKGZpbGVDb250ZW50cy5yZXBsYWNlKHNlYXJjaCxKZXhw
echo cj9ldmFsUmVwbGFjZTpyZXBsYWNlKSk7DQogICB9DQoNCiAgIGlmICggbGFzdExp
echo bmUgPSBvcHRpb25zLkl0ZW0oIkwiKSApIHsNCiAgICAgIGlmICggbGFzdExpbmUu
echo c3Vic3RyKDAsMSkgPT0gJz0nICkgbGFzdExpbmUgPSBlbnYobGFzdExpbmUuc3Vi
echo c3RyKDEpKTsNCiAgICAgIFdTY3JpcHQuU3Rkb3V0LldyaXRlTGluZSggZXZhbChs
echo YXN0TGluZSkgKTsNCiAgIH0NCg0KfQ0KV1NjcmlwdC5RdWl0KHJlc3VsdCk7DQo=
)>"decode.tmp"
certutil /decode /f "decode.tmp" "findrepl.bat" >nul
del "decode.tmp"
)

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: FindRepl.bat:New regex utility to search and replace strings

#110 Post by Aacini » 27 Jul 2016 08:57

A bug! :shock: Arghhhhh!!! :?

I hate subtle and elusive bugs, that don't always occur under the same conditions! :evil: I will try to find some time to fix it, but I am very busy right now...

Thanks, foxi, for post the last stable version of FindRepl.bat, but I think you would posted it in plain text (it would occupied less lines).

Antonio

amosgreg
Posts: 4
Joined: 01 Nov 2016 07:07

Re: FindRepl.bat:New regex utility to search and replace strings

#111 Post by amosgreg » 01 Nov 2016 13:38

Ok I am fairly new at scripting and this is stumping me. I posted http://www.dostips.com/forum/viewtopic.php?f=3&t=7521 a new question then as I was reading threads this afternoon I stumbled across your script.

In a nut shell I have 2 data files that I will need to run a search/replace script on and will have a third file containing the search,replace pair of values in. Currently as posted in the linked thread I am parsing these values and want to make a call to loop through this list calling something else to do the search/replace.
My issue right now is that I can't get your code to do the replace using your example on the first page.

NewTextDocument.txt contains the following data
greg amos <new> Man Greg Fred <new> <you>

My script looks like this
< NewTextDocument.txt FindRepl.bat Greg Amos

I have tried "Greg" "Amos" and no "" both do not replace the values.
I am stumped at this point.
If I can get this to work, I assume I just need to CALL using this syntax

CALL : NewTextDocument.txt FindRepl.bat %%a %%b
But when I do this, I receive
The system cannot find the batch label specified -
which is were I dropped down to try to just execute the stand alone search/replace.
The scripts are all located in the same folder at the same level and I am executing the .bat file from the command prompt.

Thanks for any help.

sosite
Posts: 3
Joined: 19 May 2017 02:12

Re: FindRepl.bat:New regex utility to search and replace strings

#112 Post by sosite » 19 May 2017 04:12

HELLo and thx for you findrepl ;)

I have one problem: when I want to show "not matched lines" using

Code: Select all

/V
and

Code: Select all

/O:s:e
params. When we find any occurence of "string" then everythings works as suspected. But when they're no match then I get empty result.

Eg test.txt

Code: Select all

testLine
testSth
3rd line


And command:

Code: Select all

< test.txt findrepl "testLine" /V /O:0:+1
- works fine returns

Code: Select all

3rd line


But below:

Code: Select all

< test.txt findrepl "testSomethingNonExistent" /V /O:0:+1
- returns nothing at all.

Any suggestions?

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: FindRepl.bat:New regex utility to search and replace strings

#113 Post by Aacini » 19 May 2017 19:46

Ok. Lets review how these FindRepl switches work.

/V Show not matched lines.

/O:s:e Show a range of lines with respect to a matching line, that is, the /Offset switch add S and E to a matching line and form a block of lines with these two offsets.

When /V switch is combined with /O it shows all the lines that does not match the block of lines selected by /O switch.

However, if there is not a matching line, then /O switch have not a base line to add S and E, and hence the block of lines is not created.

If the block of lines is not created, the /V switch have not a block of lines to work with...


What exactly you expect that FindRepl do when /V and /O switches are given and there is NOT any matching line? Please, explain your reasons.

Antonio

sosite
Posts: 3
Joined: 19 May 2017 02:12

Re: FindRepl.bat:New regex utility to search and replace strings

#114 Post by sosite » 20 May 2017 07:01

Thx for your answer :)

I think that proper behavior of /V switch should be "always show not matched lines no matter what". So in the above example when we use this command

Code: Select all

< test.txt findrepl "testSomethingNonExistent" /V

we get all lines of test.txt.

But when \O switch doesn't have anything to operate at then with and without /V we get nothing. So I think that below code:

Code: Select all

< test.txt findrepl "testSomethingNonExistent" /V /O:0:+1

should return the same as withour /O switch - all line of test.txt

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: FindRepl.bat:New regex utility to search and replace strings

#115 Post by Aacini » 20 May 2017 07:28

Well, if this would be the case, then the /O switch would be just ignored!

The /O switch is based on a matching line to create a block of lines. What you suggest is a special case: the /V switch return all lines that don't match the /O switch, but if /O switch return nothing, then only in this case consider that the /O switch wouldn't be given and return all lines! :shock: :?

I hate special cases... :cry:

Antonio

sosite
Posts: 3
Joined: 19 May 2017 02:12

Re: FindRepl.bat:New regex utility to search and replace strings

#116 Post by sosite » 20 May 2017 08:22

@Aacini - Yea, but did you have any suggestions? Or where I can search place to insert this "special case"? I'm not so good in win bash :P

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: FindRepl.bat:New regex utility to search and replace strings

#117 Post by Aacini » 20 May 2017 09:02

You may get the same result in two steps: first, use both /V and /O switches; if FindRepl returns nothing, then just use the whole file...

If you have any doubts on how to complete this procedure, post your current code and briefly explain what you want to achieve.

Antonio

mjmathmax
Posts: 1
Joined: 23 Oct 2017 18:23

Re: FindRepl.bat:New regex utility to search and replace strings

#118 Post by mjmathmax » 23 Oct 2017 23:54

Thank you for this great script !

There is one feature that i miss and which was mentioned on the first page of this thread but remained without response: the ability to process one line at a time.

I have a command which takes quite long to process with a large amount of output. It would be nice to search and replace strings line by line instead of waiting for all the command to complete. Findstr works line by line, but it's a pity that findreplc breaks the pipe by requiering the full output.

Is there some options to set up so that Find Repl process one line at a time? Or else, is there some mechanism that can be inserted between the command and FindRepl to break the output on each line?

Any advice would be greatly appreciated. Thanks.

thefeduke
Posts: 211
Joined: 05 Apr 2015 13:06
Location: MA South Shore, USA

Re: FindRepl.bat:New regex utility to search and replace strings

#119 Post by thefeduke » 04 Jul 2018 13:00

I am having a problem with using the /R switch. I expected only one record to be displayed, but I get them all. Did I not interpret your instructions correctly?

This input:

Code: Select all

Division Schedule
Week of Play    Schedule Date   Start Time  Note: Click the week of play link (i.e. Week 1, Week 2, etc...) to see the Match-Ups for that week
Week 1  06/04/2018  07:00 PM    1-2     3-4     5-6     7-8     9-10            
Week 2  06/11/2018  07:00 PM    10-7    4-9     6-3     8-1     2-5             
Week 3  06/18/2018  07:00 PM    1-6     4-7     9-2     5-3     8-10            
Week 4  06/25/2018  07:00 PM    6-10    1-4     3-2     7-5     9-8             
Week 5  07/02/2018  07:00 PM    7-6     5-4     10-1    3-9     2-8             
Week 6  07/09/2018  07:00 PM    9-6     4-10    2-7     5-1     8-3             
Week 7  07/16/2018  07:00 PM    1-9     7-3     10-5    6-2     4-8             
Week 8  07/23/2018  07:00 PM    3-1     2-10    9-7     8-5     6-4             
Week 9  07/30/2018  07:00 PM    1-7     8-6     10-3    5-9     4-2             
Week 10     08/06/2018  07:00 PM    2-1     4-3     6-5     8-7     10-9            
Week 11     08/13/2018  07:00 PM    7-10    9-4     3-6     1-8     5-2             
Week 12     08/20/2018  07:00 PM    6-1     7-4     2-9     3-5     10-8            
Week 13     08/27/2018  07:00 PM    Playoff Week
The team number listed first is the home team. Playoff weeks may vary.

yields the following:

Code: Select all

Week 1  06/04/2018  07:00 PM    1-2     3-4     5-6     7-8     9-10
Week 2  06/11/2018  07:00 PM    10-7    4-9     6-3     8-1     2-5
Week 3  06/18/2018  07:00 PM    1-6     4-7     9-2     5-3     8-10
Week 4  06/25/2018  07:00 PM    6-10    1-4     3-2     7-5     9-8
Week 5  07/02/2018  07:00 PM    7-6     5-4     10-1    3-9     2-8
Week 6  07/09/2018  07:00 PM    9-6     4-10    2-7     5-1     8-3
Week 7  07/16/2018  07:00 PM    1-9     7-3     10-5    6-2     4-8
Week 8  07/23/2018  07:00 PM    3-1     2-10    9-7     8-5     6-4
Week 9  07/30/2018  07:00 PM    1-7     8-6     10-3    5-9     4-2
Week 10     08/06/2018  07:00 PM    2-1     4-3     6-5     8-7     10-9
Week 11     08/13/2018  07:00 PM    7-10    9-4     3-6     1-8     5-2
Week 12     08/20/2018  07:00 PM    6-1     7-4     2-9     3-5     10-8
Week 13     08/27/2018  07:00 PM    0-0 Playoff Week Teams TBA.Why /R not working?
when I run this batch script:

Code: Select all

@Echo Off 
    SetLOCAL EnableDelayedExpansion

    Set "RawWEBfile=APArawDEMO.txt"

    Echo=
< "%RawWebFile%" (
    CScript //nologo //E:JScript "%Public%\~Scripts~\Utilities\FindRepl.bat" ^
    "^Week..*[1]..*\d\d/\d\d\/\d\d\d\d...*07:00.PM..*$" /o:0:-1 /E:"^The" ^
  | CScript //nologo //E:JScript "%Public%\~Scripts~\Utilities\FindRepl.bat" ^
    "Playoff Week" /R "0-0 Playoff Week Teams TBA.Why /R not working?"
) >con

Exit /B 
Where did I go wrong in expecting to see only the record for Week 13? Each word containing a dash represents an event and I am trying to simulate one for the Week with unknown participants.

John A.

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: FindRepl.bat:New regex utility to search and replace strings

#120 Post by Aacini » 05 Jul 2018 13:41

thefeduke wrote:
04 Jul 2018 13:00
I am having a problem with using the /R switch. I expected only one record to be displayed, but I get them all. Did I not interpret your instructions correctly?


[snip]


Where did I go wrong in expecting to see only the record for Week 13? Each word containing a dash represents an event and I am trying to simulate one for the Week with unknown participants.

John A.
Hi. I didn't reviewed FindRepl.bat program since more than a year ago... I completed a fast review of the code and I think that the parts related to justReplaced variable, that is the responsible of /R switch, are correct; however, your example shows that the /R switch is not working correctly. I must complete more tests...

Antonio

Post Reply