Code: Select all
@echo off
setlocal EnableDelayedExpansion
for /F "delims=" %%a in (test.txt) do set "string=%%a"
echo !string!
echo/
for /F "delims=" %%a in (^"!string:^<br^>^=^<br^>^
% Do NOT remove this line %
!^") do (
echo %%a
)
Antonio
Moderator: DosItHelp
Code: Select all
@echo off
setlocal EnableDelayedExpansion
for /F "delims=" %%a in (test.txt) do set "string=%%a"
echo !string!
echo/
for /F "delims=" %%a in (^"!string:^<br^>^=^<br^>^
% Do NOT remove this line %
!^") do (
echo %%a
)
Code: Select all
@echo off
jrepl "\x11\x3C\xC9\x31\x01\x0C\x60\x7C\x04\x8E\xD4\x31\x01\x0C\x60\x7C\x04\x8E\xCD\x5A" "\x11\x3C\xCE\x31\x01\x0C\x60\x7C\x04\x8E\xD4\x31\x01\x0C\x60\x7C\x04\x8E\xCD\x5A" /m /x /f dumpin.bin /o dumpout.bin
pause
Code: Select all
@echo off
for /f "delims=" %%a in ('dir /b /a-d "GAME\*.txt" ') do (
call JREPL "\n" "|" /inc "/^BEGIN$/+1:/^END$/-1" /x /f "GAME\%%~a" /o -
)
Code: Select all
Preserve 1
Preserve 2
BEGIN
A
B
C
END
Preserve 3
Preserve 4
Code: Select all
Preserve 1
Preserve 2
BEGIN
A|B|C
END
Preserve 3
Preserve 4
Code: Select all
@echo off
for %%F in ("GAME\*.txt"') do (
call jrepl "(^BEGIN\r?\n)([\s\S]*?)(?=\nEND$)" "$txt=$1+$2.replace(/\r?\n/gm,'|')" /jq /m /f "%%F" /o -
)
Code: Select all
<ab>.......................<td>
<\ab>......................<\td>
<efg>......................<tr>
<\efg>.....................<\tr>
<hij lang="en-us"><td>.....<td><hij lang="en-us">
<hij lang="xx"><td>........<td><hij lang="xx">
xml:lang=".................lang="
Code: Select all
(<\?)ab>........................\1td>
(<\?)efg>.......................\1tr>
(<hij lang=".+?">)(<td>)........\2\1
xml:lang="......................lang="
Code: Select all
@echo off
call jrepl "(<\?)ab>|(<\?)efg>|(<hij lang=".+?">)(<td>)|xml:lang=" ^
"\1td>|\1tr>|\2\1|lang=" /x /t "|" /f "input.txt" /o "output.txt"
NopeArc wrote:I only know \1 should be $1. But I don't know what else to do anymore.
Code: Select all
The search expressions may be regular expressions, possibly with
captured groups. Note that each expression is itself converted into
a captured group behind the scene, and the operation is performed
as a single search/replace upon execution. So backreferences within
each regex, and $n references within each replacement expression,
must be adjusted accordingly. The total number of expressions plus
captured groups must not exceed 99.
Code: Select all
Pig Latin - This example shows how /T can be used with regular
expressions, and it demonstrates how the numbering of captured
groups must be adjusted. The /T delimiter is set to a space.
The first regex is captured as $1, and it matches words that begin
with a consonant. The first captured group ($2) contains the initial
sequence of consonants, and the second captured group ($3) contains
the balance of the word. The corresponding replacement string moves
$2 after $3, with a "-" in between, and appends "ay".
The second regex matches any word, and it is captured as $4 because
the prior regex ended with group $3. Because the first regex matched
all words that begin with consonants, the only thing the second
regex can match is a word that begins with a vowel. The replacement
string simply adds "-yay" to the end of $4. Note that $0 could have
been used instead of $4, and it would yield the same result.
echo Can you speak Pig Latin? | jrepl^
"\b((?:qu(?=[aeiou])|[bcdfghj-np-twxz])+)([a-z']+)\b \b[a-z']+\b"^
"$3-$2ay $4-yay" /t " " /i
-- OUTPUT --
an-Cay you-yay eak-spay ig-Pay atin-Lay?
Code: Select all
$2
$1 = "(<\?)ab>" --> "$2td>"
$4
$3 = "(<\?)efg>" --> "$4tr>"
$6 $7
$5 = "(<hij lang=\q.+?\q>)(<td>)" --> "$7$6"
$8 = "xml:lang=\q" --> "lang=\q"
Code: Select all
$8 = "xml:(?=lang=\q)" --> ""
Code: Select all
call jrepl "(<\?)ab>|(<\?)efg>|(<hij lang=\q.+?\q>)(<td>)|xml:(?=lang=\q)" ^
"$2td>|$4tr>|$7$6|" /x /t "|" /f "input.txt" /o "output.txt"
dbenham wrote:Argh. That should not be
Your search and replace strings are the same length, and you have properly used the /M option, so the size should not change.
I definitely would like to have access to the file so I can test. But I am pretty sure you cannot add an attachment that large to this site. So you will have to use some external service and provide a link in your post here. I'm familiar with dropbox, but there are lots of other options. If you prefer, you can send me a private message with the link to the file.
Dave Benham
dbenham wrote:Argh. That should not be
Your search and replace strings are the same length, and you have properly used the /M option, so the size should not change.
I definitely would like to have access to the file so I can test. But I am pretty sure you cannot add an attachment that large to this site. So you will have to use some external service and provide a link in your post here. I'm familiar with dropbox, but there are lots of other options. If you prefer, you can send me a private message with the link to the file.
Dave Benham
LM459 wrote:I just found out about JREPL and have downloaded it. I am having trouble trying to do the following.
I have a number of text files that contain the "|" character, where a line break should be present.
I would like to replace the "|" character with the 2-character HEX value of 0D 0A (Carriage return/line break), but I am not having any luck with the formatting of the instruction.
I am attempting type oldfile.txt jrepl "\|" "\u0D0A" /X >> newfile.txt, as a test, but the result is not what I'm expecting.
Can someone please provide the proper syntax to accomplish this task.
Thanks!
Code: Select all
jrepl.bat "\u007C" "\r\n" /x /m /f oldtextfile.txt /o newtextfile.txt
Code: Select all
@chcp 65001>nul
@echo off
echo.
echo Drag your txt folder!
echo.
set /p fullpath=
for /f "delims=" %%? in ('dir /b /s "%fullpath:"=%\"*.txt') do (
call jrepl.bat "\u007C" "\r\n" /x /m /f "%%?" /o "%%~dp?/%%~n?_newfile.txt"
)
Code: Select all
@set @a=0 // & cscript //nologo //E:JScript "%~F0" < oldfile.txt > newfile.txt & goto :EOF
WScript.Stdout.Write(WScript.Stdin.ReadAll().replace(/\|/g,"\r\n"));
Code: Select all
Sri Advaita
Bhagavad Gita
Saptaham
Maha Bali Puram
Code: Select all
Sri Advaita,Sri Avaidta,rSi vAdiata,atiavdA irS,irS atiavdA
Bhagavad Gita,Bhvaagad Gtia,avBgahd tiGa,atiG davagahB,davagahB atiG
Saptaham,Sahaptam,tpahaaSm,mahatpaS,mahatpaS
Maha Bali Puram,Mhaa Blai Parum,ahMa lBai arPum,maruP ilaB ahaM,ahaM ilaB maruP
Code: Select all
"
{Delete " and the two lines with above.}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Maecenas egestas efficitur lobortis.
"
{Don't delete the two lines above.}
Vestibulum id dui nec nisi mattis tristique.
Donec pretium felis eu odio iaculis maximus.
Code: Select all
JREPL.BAT "\q\r\n\r\n" "" /INC "1:3" /m /x /f
"input.txt" /o output.txt
"The /INC option is incompatible with /M and /S."