JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
Moderator: DosItHelp
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
Thanks a lot for feedback, that is much appreciated.
I am pretty new to this so I will give it a try and experiment on it...
Riko
I am pretty new to this so I will give it a try and experiment on it...
Riko
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
Hello there,
For a dailly usage case in which all files in a folder need to be converted from utf-8 to utf-16 is this script suited ?
So, just run manually script when needed.
Thanks a lot
For a dailly usage case in which all files in a folder need to be converted from utf-8 to utf-16 is this script suited ?
So, just run manually script when needed.
Thanks a lot
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
Converting utf-8 to utf-16 could be done with JREPL, but you would get much better performance with aGerman's CONVERT.exe. Its sole purpose is to convert text files from one encoding to another.
Both utilities process only one file, so you would have to process an entire folder using a FOR loop either way.
Both utilities process only one file, so you would have to process an entire folder using a FOR loop either way.
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
JREPL might be a real good choice because it's a script which works with on-board resources.
CONVERTCP has the disadvantage of being a 3rd party executable. However, if performance matters (e.g. due to big files or a lot of text in total) it might be more suitable for you.
(Direct overwriting of the original file is not supported on purpose.)
Beware of running those scripts twice on the same files!
Steffen
Code: Select all
for %%i in ("*.txt") do cmd /c jrepl "^" "" /f "%%~i|UTF-8" /o "-|UTF-16"
CONVERTCP has the disadvantage of being a 3rd party executable. However, if performance matters (e.g. due to big files or a lot of text in total) it might be more suitable for you.
Code: Select all
for %%i in ("*.txt") do convertcp "UTF-8" "UTF-16" /b /i "%%~i" /o "%%~i.tmp~" && move /y "%%~i.tmp~" "%%~i"
Beware of running those scripts twice on the same files!
Steffen
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
Hi,
I'm new to JREPL and this level of regex, forgive me if this has been covered in the previous 484 posts.
I've got an expression working on regex101 here but it doesn't seem to work with JREPL.
It worked when there was only one "[0-9]+" but having a second one after the "e" seems to break it.
Essentially I'm trying to add a setting to a text file, where the settings only exist there if they're different to default.
So I find the setting that is always next to it, which has dynamic numbers before and after the "e" character.
I'm new to JREPL and this level of regex, forgive me if this has been covered in the previous 484 posts.
I've got an expression working on regex101 here but it doesn't seem to work with JREPL.
Code: Select all
(hello_worldi[0-9]+e[0-9]+)
Essentially I'm trying to add a setting to a text file, where the settings only exist there if they're different to default.
So I find the setting that is always next to it, which has dynamic numbers before and after the "e" character.
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
https://regex101.com/r/UnSIRS/1
Im attempting to make this regex work. Does work with regex101.
Regex - <AppSet>[\r\s]*?<Applicator>[\r\s]*?<plMatrixChannelApplicator>[\r\s]*?.*Pinky((?!<\/AppSet>))[\s\S]*?<\/AppSet>
Any Help is appreciated. Thank you
Im attempting to make this regex work. Does work with regex101.
Regex - <AppSet>[\r\s]*?<Applicator>[\r\s]*?<plMatrixChannelApplicator>[\r\s]*?.*Pinky((?!<\/AppSet>))[\s\S]*?<\/AppSet>
Any Help is appreciated. Thank you
-
- Posts: 3
- Joined: 22 Aug 2021 17:57
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
Hello,
I'm struggling with a difficulty to use JREPL.bat for my goal. Hope someone can help me
I have this code :
What i want is to find the hiddenFeatures line and replace the "Freaky bird;joy;ekett;prorata;great;super;beautiful" that is between quote. This value change everytime so actually i've tried :
But it doesn't work. Can somenone help ?
Thanks in adavance,
I'm struggling with a difficulty to use JREPL.bat for my goal. Hope someone can help me
I have this code :
Code: Select all
<config>
<bool name="audio.bgmusic" value="false" />
<bool name="global.achievements" value="true" />
<string name="listViewStyle" value="Spin" />
<string name="HiddenFeatures" value="Freaky bird;joy;ekett;prorata;great;super;beautiful" />
<string name="Language" value="us_US" />
</config>
Code: Select all
setlocal enableDelayedExpansion
set "newValue=myNewValue"
type "settings.cfg"|jrepl "(<string name="HiddenFeatures" value=").*(" />)" "$1!newValue!$2" >fileName.cfg.new
Move /y "fileName.cfg.new" "settings.cfg"
Thanks in adavance,
Last edited by aGerman on 23 Aug 2021 10:08, edited 1 time in total.
Reason: code formatting
Reason: code formatting
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
Use extra escape sequences (option /XSEQ) in order to to be able to use \q rather than quotes in your pattern.
Also, JREPL supports overwriting of the input file.
Steffen
Also, JREPL supports overwriting of the input file.
Code: Select all
setlocal enableDelayedExpansion
set "newValue=myNewValue"
cmd /c jrepl "(<string name=\qHiddenFeatures\q value=\q).*(\q />)" "$1!newValue!$2" /XSEQ /F "settings.cfg" /O -
-
- Posts: 3
- Joined: 22 Aug 2021 17:57
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
It works perfectly, thanks !
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
Hi there.
I've got this batch to extract the text between wordA and wordB from a text file: wordA----------text1-----------wordB
It works when there are only one set of wordA and wordB. It returns i.e. "----------text1-----------"
However, if the wordB appears more than once, e.g. wordA----------text1-----------wordB-------text2-------------wordB
then output is all the text between the first wordA and the last wordB, i.e. "----------text1-----------wordB-------text2-------------"
How can I make it return the text between the first "wordA" and the first "wordB"?
Example:
If I set wordA to content":" and wordB to "
The output of the above script is: This is my text","status":200,"error_code
What I want is: This is my text
Your help is much appreciated.
I've got this batch to extract the text between wordA and wordB from a text file: wordA----------text1-----------wordB
Code: Select all
@echo off
type infile |jrepl ".*wordA(.*)wordB.*" "$1" > outfile
However, if the wordB appears more than once, e.g. wordA----------text1-----------wordB-------text2-------------wordB
then output is all the text between the first wordA and the last wordB, i.e. "----------text1-----------wordB-------text2-------------"
How can I make it return the text between the first "wordA" and the first "wordB"?
Example:
Code: Select all
{"info":"OK","content":"This is my text","status":200,"error_code":0}
The output of the above script is: This is my text","status":200,"error_code
What I want is: This is my text
Your help is much appreciated.
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
Code: Select all
cmd /c jrepl.bat ".*\qcontent\q:\q(.+?(?=\q)).*" "$1" /XSEQ /F "infile" /O "outfile"
Steffen
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
Many thanks, Steffen. It works as expected!!!
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
I'm struggling to do a JPREL operation on a simple XML (GPX) file. The section I want to delete (complete with line-feeds) is as follows:
So what am I doing wrong here?
I think it's something to do with line-feeds. I've tried \r \n amongst others, and I believe the file is UTF-8. Not sure if I have the /M switch in the correct place, or even if I need it?
Code: Select all
<extensions>
<mmttimezone>+01:00</mmttimezone>
</extensions>
Code: Select all
Call jrepl "\<extensions\>\s.*?\s\<\/extensions\>\s" "" /M/f MMT.gpx /o -
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
If you want to use \r and \n you have to pass option /XSEQ.
That should work:
Steffen
That should work:
Code: Select all
Call jrepl "\<extensions\>\r\n.*?\r\n\<\/extensions\>\r\n" "" /XSEQ /M /F "MMT.gpx" /O -
Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
Many thanks, that did it!aGerman wrote: ↑06 Oct 2021 10:30If you want to use \r and \n you have to pass option /XSEQ.
That should work:SteffenCode: Select all
Call jrepl "\<extensions\>\r\n.*?\r\n\<\/extensions\>\r\n" "" /XSEQ /M /F "MMT.gpx" /O -