Page 35 of 37

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

Posted: 12 Nov 2021 14:57
by sk8ordie
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

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

Posted: 13 Nov 2021 06:04
by aGerman
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

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

Posted: 13 Nov 2021 06:39
by sk8ordie
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?

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

Posted: 13 Nov 2021 06:47
by aGerman
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

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

Posted: 13 Nov 2021 06:53
by sk8ordie
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"
)

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

Posted: 13 Nov 2021 07:14
by aGerman
Huh, what is this loop for?

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

Posted: 13 Nov 2021 09:04
by sk8ordie
yes, indeed the loop is pointless there
just found it in an example and it worked, so I didn't touch it

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

Posted: 13 Nov 2021 09:35
by aGerman
Copy pasta has a rotten taste. It's critical to understand the code you're using.

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

Posted: 27 Jan 2022 11:34
by paolo2504
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

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

Posted: 27 Jan 2022 12:00
by Squashman
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.

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

Posted: 28 Jan 2022 03:29
by paolo2504
Thank you i fixed the issue and now script is working. I did mi state in using quotes.

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

Posted: 23 Mar 2022 05:10
by dixxia
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:

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

Posted: 23 Mar 2022 05:52
by aGerman
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

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

Posted: 23 Mar 2022 19:52
by AR Coding
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"

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

Posted: 23 Apr 2022 11:53
by syrist
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.