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
Squashman
Expert
Posts: 4206
Joined: 23 Dec 2011 13:59

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

#466 Post by Squashman » 30 Jul 2020 16:47

dbenham wrote:
30 Jul 2020 16:22
Here is JREPL version 8.6
Still waiting for the infomercial to order JREPL for Dummies. Only $19.99. And if you order within the next 5 minutes we will waive the shipping and handling fee.

dbenham
Expert
Posts: 2404
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

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

#467 Post by dbenham » 30 Jul 2020 17:20

:lol: Good idea, but its not gonna be written by me.

I do wonder what I would have received if JREPL was shareware with a suggestion of $5 per user. I did receive an unsolicited donation from one user - that was pretty cool, and a total surprise.

If I ever write the compiled .NET version (major rewrite and syntax changes) then it will definitely be shareware instead of freeware. And it wouldn't be released on DosTips. But right now I would rather invest my time on my music.

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

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

#468 Post by Squashman » 30 Jul 2020 18:24

dbenham wrote:
30 Jul 2020 17:20
But right now I would rather invest my time on my music.
That "sounds" like the right decision. I spent more time on my bicycles this year. It was the only way to escape the quarantine insanity.

audi02
Posts: 1
Joined: 07 Sep 2020 05:32

Re: JREPL.BAT v8.6 - can't get correct result when using [^]

#469 Post by audi02 » 07 Sep 2020 06:10

Hi,
FYI

I tried JREPL with the follow scenario:

Input string: "PROXY proxy-aaa.bbbbbb.com:789"

command: jrepl ".*[^0-9A-Za-z\.]([0-9A-Za-z\.]+):([0-9]+).*" "$1:$2"

Result: "m:789"
Expected result: "aaa.bbbbbb,com:789"

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

#470 Post by aGerman » 07 Sep 2020 12:26

How exactly did you use it? Just because I can't repreduce your result.

Code: Select all

C:\Users\neffe\Desktop>echo PROXY proxy-aaa.bbbbbb.com:789|jrepl ".*[^0-9A-Za-z\.]([0-9A-Za-z\.]+):([0-9]+).*" "$1:$2"
aaa.bbbbbb.com:789
Steffen

Zamprosco
Posts: 2
Joined: 28 Oct 2020 02:28

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

#471 Post by Zamprosco » 28 Oct 2020 02:43

Hello, thanks for the wonderful work.
I downloaded the latest version and had a look at it.
As a complete novice to Batch, im overwhelmed by the info for what i want to achieve.
I will like to swap position for some entries in a .txt file.

Ex:
Original text : 511 [SomeText0] SomeText1 SomeText2 SomeText3
Objective : SomeText1 SomeText2 SomeText3 511 [SomeText0]

Can you please help me understand how to go about achieving that.

Thank you very much.

Regards

Ridim
Posts: 2
Joined: 24 Jun 2020 06:40

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

#472 Post by Ridim » 28 Oct 2020 09:31

A big thanks to you @Frits!

I got some spare time to clean my dirty json format file and to display it in html format.

Your comands did the trick pretty well, now I understand better how this powerfull script is working.

I got a question for you, I'm trying to clean some other sides of my json and I want t use this part :

Code: Select all

 jrepl "(?:{*?\qimage\q:)(?:(.*?)\?Expires)(?:.*?)$" "<img src=$1\q /><p>"
Can someone explain me how to define the begin char and the end char ? I did'nt found out the correct syntax to use it.

(?:{*? = ?

:)(?:(.*?)\? = take all chars between : and ?

)(?:.*?)$ = ?

Thanks again for your time!

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

#473 Post by aGerman » 28 Oct 2020 11:14

@Zamprosco
What is your regex pattern to reliably separate the strings into the 5 groups you mentioned? I mean, we are talking about regular expressions which means you have to be able to clearly define the rules of how to do that. https://regex101.com/ is a good place to develop the pattern and once you got it we're certainly able to help out with the JREPL command line to rearrange the grouped substrings.

Steffen

Zamprosco
Posts: 2
Joined: 28 Oct 2020 02:28

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

#474 Post by Zamprosco » 28 Oct 2020 14:57

@aGerman
Thank you very much for your input.

Regex pattern !? no wonder i was lost as to how to get things going. There is a prior need to understand regex. The name alone makes me feel uneasy.
I m renouncing the bid for automation.
Thank you very much.

Regards

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

#475 Post by aGerman » 28 Oct 2020 15:05

Zamprosco wrote:
28 Oct 2020 14:57
Regex pattern !?
Yeah, that's what the topic of this thread already says. Could be something quite simple. But certainly nothing we are able to make out of your example without any explanation of how the real data look like.

Steffen

Martias
Posts: 2
Joined: 30 Oct 2020 07:53

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

#476 Post by Martias » 30 Oct 2020 08:17

Good day to everyone

Well this is my first time asking a question here :) So please bear with me.
I read here for a long time, cause JREPL is just so good and it helped me already to great legth with various tasks.
I slowly climb my way up to understand it deeper and deeper, but to be honest, i really struggle with regula expressionsits not even funny.

I now have a task at hand that goes definately beyound my knowledge. I already did serval approaches and tried to read snippets online to
find som ething that helps me.. but to no avail.
So finally i come to seek for help.

To the case
I get a exported file on a regular basis. Till now i just edited it by hand. But the export becomes steadily bigger and bigger and editing by hand costs too much time now.
Soooo to makes things worse. that piece of gar.. err useful software generate a totally trashed errr difficult to handle .csv file.
I mean its called a .csv file, not that it resembles any .csv that i ever saw. ..... Ok enough rambling.

One part of that report also includes the complete e-mail someone send. Unfortunately the exporter in unable to handle some of the formatting and little
"beauty" tricks some people do with their e-mail.
So i have a lot of nonsense in that mail. I really want to get rid of the entire Mailtext in one go, since its not needed for what happens afterward with it.

I can spot a uniqe point where i can start the elemination process.
That is the part "To:" the beginning of that passage starts always with To:
and the end of that said mail is always a double semicolon. So ;;

I want to get rid of everything that is between those two things
To: random length text with all sort of formats and special characters ;;
that has all to go.
I already managed to delete everything after the To: but i really dont get how i stop at the next ;;
As i said, i really struggle with the regular expressions
Also there are serval of those passages in the exportet file. Maybe someone here can help me?
So many thanks :)

Klaus

dbenham
Expert
Posts: 2404
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

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

#477 Post by dbenham » 30 Oct 2020 09:34

Assuming the entire string is on a single line, then it is a rudimentary regular expression, though I wouldn't be surprised if your file had other text that might be mistakenly identified by the simple regular expression:

Code: Select all

jrepl "To:.*?;;" "" /i input.csv /o output.csv
Explanation:
To: - self explanatory string literal
.* - matches any 0 or more characters (except newline)
? - makes the previous expression non-greedy, meaning match the minimum number of characters possible that allows the overall expression to match.
;; - self explanaory

In English - Match starting with To: and ending with the earliest subsequent appearance of ;;

If your CSV has quoted fields with newlines, then you need to enable multi-line searches, and change the .* into something that will match truly any character.

Code: Select all

jrepl "To:[\s\S]*?;;" "" /m /i input.csv /o output.csv
\s matches any whitespace character (space, tab, vertical-tab, carriage-return, form-feed, newline)
\S matches any character that is not whitespace
So the character set [\s\S] matches truly any character

To be able to tap into the power of JREPL, you really need to learn regular expressions, and this is not the place to learn. There are loads of regular expression tutorials on the internet. You can ask regular expression questions on StackOverflow using the regex tag. And a quick web search finds multiple dedicated regular expression forums.

Martias
Posts: 2
Joined: 30 Oct 2020 07:53

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

#478 Post by Martias » 30 Oct 2020 10:02

Many many thanks for the reply :)
I really appreciate this.

And you are right, i really should invest more time in learning about regular expressions.
As we saw here, it is an essential.

I will go and study more.
Thank you again for the helping hand!

bobax
Posts: 2
Joined: 13 Nov 2020 04:10

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

#479 Post by bobax » 13 Nov 2020 05:29

Hi all,

This is my first post here too. I found out yesterday about this little processor and tried to apply it to replace characters on a large numbers of csv files.
Basically, after some faffing around, I managed to find the correct syntax for a single file in a folder (it works great and it also super fast)
type *.csv |jrepl "\." "/" |jrepl "\," "." >output.csv

Now when i tried to apply it to multiple files in a folder and overwrite original files, I get some error
type *.csv |jrepl "\." "/" |jrepl "\," "." /o -

Any help would be much appreciated

Regards

Riko

dbenham
Expert
Posts: 2404
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

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

#480 Post by dbenham » 13 Nov 2020 17:51

The documentation is pretty clear that /O - only works if you use /F to specify the input file name. It certainly does not work with a pipe. Also, it is simple to TYPE multiple files into a pipe, but then there is no concept of a file anymore - just one continuous stream.

If you want to use JREPL to overwrite the original file, then you must use the /F "file" and /O - options. JREPL only processes one file at a time, so you will need a FOR loop to call JREPL once for each file.

You are simply trying to substitute / for a period and period for a comma. You accomplish that using two JREPL calls (via pipes). It is simple to do this in one step with the /T option. You can use the /L option to do a literal search so you don't need to escape your search strings.

Code: Select all

for %%F in (*.csv) do call jrepl ". ," "/ ." /l /t " " /f "%%F" /o -
The above assumes a batch file. Use %F if you run directly from the command line.


Dave Benham

Post Reply