I am sorry, but I can't resist the temptation of post this reply...
Both dbenham's JREPL.BAT and my own
FindRepl.bat programs are extensive and complex applications designed to perform advanced and very sophisticated text replacement operations. However, I never have seen that anyone of these programs be used at least at a small fraction of their capabilities! These programs are mainly sub-used, and the resources invested in they are wasted...
For example, although FindRepl.bat is very capable of extract the line # 13 of a file, IMHO it is just absurd to use a 950 lines program to achieve a result that can be obtained in a simpler way; like this one:
Code: Select all
for /F "usebackq skip=12 delims=" %%a in ("%file%") do set "line13=%%a" & goto break
:break
... or this one, that don't use a GOTO:
Code: Select all
set "line13="
for /F "usebackq skip=12 delims=" %%a in ("%file%") do if not defined line13 set "line13=%%a"
In a similar way, the replace operation shown in previous reply is finally executed in a very simple function in just one line of JScript code, so certainly you don't need a 850 lines program (like JREPL.BAT) in order to write and execute the same line in a small Batch-JScript hybrid file; for example:
Code: Select all
@set @a=0 // & cscript //nologo //E:JScript "%~F0" & goto :EOF
WScript.Stdout.Write(WScript.Stdin.ReadAll().replace(/^\s*(\w+).+/gm,"$1\r\n"));
Output example:
Code: Select all
C:\> type input.txt
events = { 910 911 }
action_clan_sentiment = {
potential = {
C:\> test.bat < input.txt
events
action_clan_sentiment
potential
You may review other examples of not-so-simple replacements that can be achieved in a few JSCript lines
here or
here...
Nor JREPL.BAT neither FindRepl.bat can avoid that the user needs to learn regular expressions in order to successfully use these programs Antonio
PS - You may use the "Search an extra string in a block of lines (/B switch)" FindRepl's feature to perform a replacement in line 13 of the file:
Code: Select all
call findrepl "" /O:13:13 /Q:' /B:"'(.*)'" "SET 'myVar2=$1'" < "%file%"