JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
sk8ordie
Posts: 13
Joined: 10 Feb 2021 03:56

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#511 Post by sk8ordie » 12 Nov 2021 14:57

I need a little help again :oops:
in a result.txt file, there is always one link, after _ps with a random numbers, and always a known numbers to insert 0000100
could all this be done with jrepl or just finding the numbers?

result.txt

Code: Select all

https://stream9.nava.hu/navahu_bdrm/_definst_/amlst:mnfa-84/manifest_w634869604_ps3854000_pd60000000_qc2Vzc2lkPSZvbXE9dHJ1ZSZucD0mbGI9NTdoN1dqVDg5N2VXVnVLUnhhQk9BYzJmS2JKWSUyQlhudGtNQXhSRWxET3BDc0ttR055T2FlRGJSbFQ5SGQyMzZ6MFpReXpmTVlBSlFMJTBEJTBBbEFxWmlOeFBqQSUzRCUzRCUwRCUwQQ==.mpd
to finding numbers i only managed to get this far
https://regex101.com/r/iv5qpv/1/
(I could not get the letter s off)

target.txt

Code: Select all

https://stream9.nava.hu/navahu_bdrm/_definst_/amlst:mnfa-84/manifest_w634869604_ps0000100_pd60000000_qc2Vzc2lkPSZvbXE9dHJ1ZSZucD0mbGI9NTdoN1dqVDg5N2VXVnVLUnhhQk9BYzJmS2JKWSUyQlhudGtNQXhSRWxET3BDc0ttR055T2FlRGJSbFQ5SGQyMzZ6MFpReXpmTVlBSlFMJTBEJTBBbEFxWmlOeFBqQSUzRCUzRCUwRCUwQQ==.mpd

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#512 Post by aGerman » 13 Nov 2021 06:04

I don't think you need to exclude the _ps from the match. Just include it in your replace string again. So, I guess what you want to do is replacing
_ps[0-9]+ with _ps0000100, right?

https://regex101.com/r/uT2dbP/1

Steffen

sk8ordie
Posts: 13
Joined: 10 Feb 2021 03:56

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#513 Post by sk8ordie » 13 Nov 2021 06:39

yes, it's good as it is, but how does the program find its way back?
if _ps is out of it?
it have no clue where to put the 0000100 numbers back, or am I getting something wrong?

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#514 Post by aGerman » 13 Nov 2021 06:47

Not sure what you're asking, honestly. _ps is not out of it as I've shown in the regex101 example. The main purpose of JREPL is replacing. This thread is full of examples. Do you have problems to understand the help documentation of JREPL?

Steffen

sk8ordie
Posts: 13
Joined: 10 Feb 2021 03:56

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#515 Post by sk8ordie » 13 Nov 2021 06:53

aGerman wrote:
13 Nov 2021 06:47
Not sure what you're asking, honestly. _ps is not out of it as I've shown in the regex101 example. The main purpose of JREPL is replacing. This thread is full of examples. Do you have problems to understand the help documentation of JREPL?

Steffen
ohh okay, now i get it :)
thank you for the guidance!

that's was a solution:

Code: Select all

@echo off
setlocal enabledelayedexpansion
set "int=_ps[0-9]+"
set "int_new=_ps0000100"
for %%i in ("result.txt") do (
    call jrepl "!int!" "!int_new!" /m /f "result.txt" /o "target.txt"
)

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#516 Post by aGerman » 13 Nov 2021 07:14

Huh, what is this loop for?

sk8ordie
Posts: 13
Joined: 10 Feb 2021 03:56

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#517 Post by sk8ordie » 13 Nov 2021 09:04

yes, indeed the loop is pointless there
just found it in an example and it worked, so I didn't touch it

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#518 Post by aGerman » 13 Nov 2021 09:35

Copy pasta has a rotten taste. It's critical to understand the code you're using.

paolo2504
Posts: 18
Joined: 27 Jan 2022 11:23

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#519 Post by paolo2504 » 27 Jan 2022 11:34

Hello.
i am stuck on trying to search&replace chars .\ with null.
i want to eliminate all occurences of ".\" in every line of a test file.
here below the Windows script (called by call :jreplcall).
No error is shown and no replacement is done.
I am sure the chars are the problem but i dont see how to fix. I tried to set quote or double quote unsuccessfully.

Code: Select all

:jreplcall
set InFile=d:\inifile.txt
set OutFile=D:\output.txt
set findchr=.\
set replchr=
call %CurrentDir%\jrepl.bat '%findchr%' '%replchr%' /f "%InFile%" /o "%OutFile%"
goto :eof
Last edited by Squashman on 27 Jan 2022 11:56, edited 1 time in total.
Reason: MOD EDIT: Please use code tags.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#520 Post by Squashman » 27 Jan 2022 12:00

paolo2504 wrote:
27 Jan 2022 11:34
Hello.
i am stuck on trying to search&replace chars .\ with null.
i want to eliminate all occurences of ".\" in every line of a test file.
here below the Windows script (called by call :jreplcall).
No error is shown and no replacement is done.
I am sure the chars are the problem but i dont see how to fix. I tried to set quote or double quote unsuccessfully.

Code: Select all

:jreplcall
set InFile=d:\inifile.txt
set OutFile=D:\output.txt
set findchr=.\
set replchr=
call %CurrentDir%\jrepl.bat '%findchr%' '%replchr%' /f "%InFile%" /o "%OutFile%"
goto :eof
1) You cannot set a variable to the NUL value like that.
2) The variable has now become undefined because there is no value assigned to it and no longer exists.

The help file explains how to use special characters as search string and replacement strings. Look at the /XSEQ option.

paolo2504
Posts: 18
Joined: 27 Jan 2022 11:23

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#521 Post by paolo2504 » 28 Jan 2022 03:29

Thank you i fixed the issue and now script is working. I did mi state in using quotes.

dixxia
Posts: 1
Joined: 23 Mar 2022 04:56

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#522 Post by dixxia » 23 Mar 2022 05:10

good day!!!

i download JREPL.BAT on my disk d:.
i have myfile.dat on d:
i need find on myfile.dat string Hex (binary) "06 ff bc 87 f3 7a"
and replace it for "54 4d ff 43 53 a7"
and save as new file out.dat
i run jrepl "\06 ff bc 87 f3 7a\b" "54 4d ff 43 53 a7" /f myfile.dat /o - but no result... Can you help me? Sorry, im not programmer :oops: :oops:

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#523 Post by aGerman » 23 Mar 2022 05:52

Specify /M to read binary data and specify /XSEQ to enable syntax \xNN for hexadecimal expressions of bytes.

Code: Select all

cmd /c jrepl.bat "\x06\xff\xbc\x87\xf3\x7a" "\x54\x4d\xff\x43\x53\xa7" /xseq /m /f "myfile.dat" /o -
Steffen

AR Coding
Posts: 53
Joined: 02 May 2021 21:16

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#524 Post by AR Coding » 23 Mar 2022 19:52

If you want to output it to a new file you will have to specify the ' /o ' switch. If you specify ' /o - ' it will overwrite the original file. You can switch it like this:

Code: Select all

cmd /c jrepl.bat "\x06\xff\xbc\x87\xf3\x7a" "\x54\x4d\xff\x43\x53\xa7" /xseq /m /f "myfile.dat" /o "out.dat"

syrist
Posts: 3
Joined: 27 May 2020 07:42

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

#525 Post by syrist » 23 Apr 2022 11:53

I love JREPL but just can't figure out how to do this one thing... I have a text file with:

Code: Select all

Line1
Line2
Line3
Line4
I would like to be able to use JRPL to remove the line feed between "LIne1" and "Line2" to a new text file with:

Code: Select all

Line1Line2
Line3
Line4
Is this possible? Thanks.

Post Reply