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
IanC
Posts: 4
Joined: 06 Oct 2021 05:49

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

#496 Post by IanC » 08 Oct 2021 05:34

IanC wrote:
07 Oct 2021 15:01
aGerman wrote:
06 Oct 2021 10:30
If you want to use \r and \n you have to pass option /XSEQ.
That should work:

Code: Select all

Call jrepl "\<extensions\>\r\n.*?\r\n\<\/extensions\>\r\n" "" /XSEQ /M /F "MMT.gpx" /O -
Steffen
Many thanks, that did it!
And if I wanted to loop through every GPX file in a directory?? I've attempted to splice together with the looping as shown here without success:
https://stackoverflow.com/questions/180 ... tch-script

Code: Select all

for /f "usebackq delims=|" %%f in (`dir /b "*.gpx"`) do call jrepl "\<extensions\>\r\n.*?\r\n\<\/extensions\>\r\n" "" /XSEQ /M /F %%f /O -
For the sake of simplicity, JREPL and my batch file are in the same directory as the files I'm attempting to process.

aGerman
Expert
Posts: 4326
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

#497 Post by aGerman » 08 Oct 2021 09:18

I'd guess that it should already work out of the box. USEBACKQ is not necessary and you also don't need the pipe as delimiter. Thus, a simple FOR will do the job. However, it may fail if the file name contains spaces or special characters like ampersands. Better quote file names represented by %%f.
Not tested:

Code: Select all

for %%f in ("*.gpx") do call jrepl "\<extensions\>\r\n.*?\r\n\<\/extensions\>\r\n" "" /XSEQ /M /F "%%~f" /O -
Steffen


Tyler
Posts: 3
Joined: 27 Oct 2021 10:55

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

#499 Post by Tyler » 27 Oct 2021 11:04

Hello everyone, I am using JREPL.BAT v8.6 to replace the text in my log file and sometimes I get below error message:

Code: Select all

 JScript runtime error: Permission denied 
or

Code: Select all

 JScript runtime error opening output file: Permission denied 
Does anyone know what could be the root cause of this issue? and how can I prevent it from happening? Thanks.

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

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

#500 Post by Squashman » 27 Oct 2021 11:42

Tyler wrote:
27 Oct 2021 11:04
Hello everyone, I am using JREPL.BAT v8.6 to replace the text in my log file and sometimes I get below error message:

Code: Select all

 JScript runtime error: Permission denied 
or

Code: Select all

 JScript runtime error opening output file: Permission denied 
Does anyone know what could be the root cause of this issue? and how can I prevent it from happening? Thanks.
Would probably help if you showed us all the code you are using, especially if it is part of a larger script.

My best guess is it is truly a permissions issue. You are trying to write to a folder you do not have permissions to but without any context it is hard to know.

Tyler
Posts: 3
Joined: 27 Oct 2021 10:55

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

#501 Post by Tyler » 27 Oct 2021 12:39

Squashman wrote:
27 Oct 2021 11:42
Tyler wrote:
27 Oct 2021 11:04
Hello everyone, I am using JREPL.BAT v8.6 to replace the text in my log file and sometimes I get below error message:

Code: Select all

 JScript runtime error: Permission denied 
or

Code: Select all

 JScript runtime error opening output file: Permission denied 
Does anyone know what could be the root cause of this issue? and how can I prevent it from happening? Thanks.
Would probably help if you showed us all the code you are using, especially if it is part of a larger script.

My best guess is it is truly a permissions issue. You are trying to write to a folder you do not have permissions to but without any context it is hard to know.
Hi Squashman,

Thanks for your reply. I am using Windows 10 and I am just trying to run below command in cmd (I did even try to run cmd as administrator).

Code: Select all

 JREPL "\bLogfile created:.*\b" "Logfile created: %date% %time%" /f "my_file.log" /o - 
Agree with you that it could be the permission issue but it is really hard to figure out as this issue is intermittent.

miskox
Posts: 400
Joined: 28 Jun 2010 03:46

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

#502 Post by miskox » 27 Oct 2021 14:15

Maybe AV locks the output file? Try disabling it and do some more tests.

Saso

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

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

#503 Post by Squashman » 27 Oct 2021 15:38

Is another program writing to that log file? If so the system would put a file lock on the file and would not allow JREPL to write back out to the same file name.

Tyler
Posts: 3
Joined: 27 Oct 2021 10:55

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

#504 Post by Tyler » 29 Oct 2021 06:52

miskox wrote:
27 Oct 2021 14:15
Maybe AV locks the output file? Try disabling it and do some more tests.

Saso
Squashman wrote:
27 Oct 2021 15:38
Is another program writing to that log file? If so the system would put a file lock on the file and would not allow JREPL to write back out to the same file name.
I tried to disable the real-time scan of AV and didn't encounter this problem anymore. It seems the AV locks the output file when scanning. Thanks all for your support.

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

#505 Post by sk8ordie » 02 Nov 2021 05:59

hello!

i want to use jrepl with batch file
but I only get an empty file (result.txt)
and an error message:
JScript runtime error in Search regular expression: Syntactic error in the regular expression

in result.txt this should be
14a3f1a9a023373f886ca2ff1f66294c:ac76bc99a93f5d849796e001208dd920

this would the regex:
https://regex101.com/r/7rVVUW/1

(?<=kili[+])([0-9,a-z:]*)

.bat

Code: Select all

@echo off
call jrepl "\c(?<=kili[+])([0-9,a-z:]*)" "" /k 0 /xseq /f need-regex.txt /o result.txt
i found this here but, i guess i didn't interpret the lieiric correctly
https://stackoverflow.com/a/51655972/15062453

thanks in advance for your help!

aGerman
Expert
Posts: 4326
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

#506 Post by aGerman » 02 Nov 2021 13:25

JScript doesn't support (?<=...) look-behind assertions. And since I didn't get /P and /PREPL working along with /MATCH, I'm afraid you need to use a two-step processing.

Code: Select all

@echo off &setlocal
call jrepl "kili\+[0-9a-f:]+" "" /MATCH /F "need-regex.txt" /O "result.txt"
call jrepl "[0-9a-f:]+" "" /MATCH /F "result.txt" /O -
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

#507 Post by sk8ordie » 03 Nov 2021 12:18

Thank you so much this is so perfect!
it doesn't matter if it's in several parts:)

nice, thousands of lines in .log, and just a second i got what I needed
brutal how effective it is :)

do you have any tips on whether any of the online regex sites are compatible with jrepl?
because without it i don't really get on with it to practice with jrepl

since this regex i not finished it so this is a bit off here
https://regex101.com/r/K4tslE/1
but maybe you can quickly clarify me if it's worth to keep trying or not to get links that are .mpd and don't look like that
.mpd? or
.mpd?sdfdsexpiration=1...
do you think jrepl could isolate it so that I only get this link?

Code: Select all

https://rtlhu.vod.6cloud.fr/rtl.hu/output/6/4/1/64151c3ec8e2e487c7dbbf04e14e0f58bb1ee15e104bf2ac6349491b7a1bdbd0/static/c12898428_web_drm_720p_dash_v1.mpd
btw this link is an another file inside, but maybe you have an idea for this one to get just the link inside? <Location>....</Location>

Code: Select all

https://stream9.nava.hu/navahu_bdrm/_definst_/amlst:183342/manifest_w621845551_pd960000_qc2Vzc2lkPVUyRnNkR1ZrWDElMkZqR0lpUSUyQjglMkJyJTJGTHlaSUZBRmM2MjFUdnhNOTBLYiUyQmEwaUR3cTNUN2c0Y3d5U3A0T3hoRFBsSGt2YkozNWZMJTJGRVNEZ3h3RTdORHlSZzhZWFhzQ2xjUVE3JTJGS3VyVUxiSzglM0RfMiZvbXE9dHJ1ZSZucD0mbGI9N2NKMkFJZUxzZDNzVU9aTW1kSCUyQncyS2xKaGdsM3BuM0txb1VLZ3Q0azA5JTJGMVlmVnBkQ1dEUjUwc0l2TmZsc3ZMNEJ5bEFLSldRU1ElMEQlMEFONFNFWVFrY3hnJTNEJTNEJTBEJTBB.mpd

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

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

#508 Post by Squashman » 03 Nov 2021 13:24

sk8ordie wrote:
03 Nov 2021 12:18
do you have any tips on whether any of the online regex sites are compatible with jrepl?
because without it i don't really get on with it to practice with jrepl
Looks like someone didn't read the JREPL help documentation.

aGerman
Expert
Posts: 4326
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

#509 Post by aGerman » 03 Nov 2021 13:29

do you have any tips on whether any of the online regex sites are compatible with jrepl?
regex101 :wink: On the left sidebar you can select ECMAScript (JavaScript).

FWIW Look-ahead assertions are supported.
https://regex101.com/r/K4tslE/2

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

#510 Post by sk8ordie » 03 Nov 2021 13:44

wow thanks for the correction, that's wonderful :)
and also thanks for the tips!

Post Reply