REGEX "Problem"

Ask questions about how to create a script or swap scripts with other users.
Post Reply
kyguy6969
Posts: 11
Joined: 01 Mar 2013 02:38

REGEX "Problem"

Post by kyguy6969 »

I have a script in another editor that I want to get away from, if I can and use RJ Text Ed. But the "deal breaker" is if I can get it to do some conversion.

Say I have this (US dates MM/DD/YYYY):

USER1234 (06/21/2012 02:34:59 PM EST)
XYZ1 (06/21/2012 03:38:14 PM EST)
ABCD (06/22/2012 06:45:05 AM EST)

What I want to do, is for the lines to become:

USER1234 (2012_06_21 1434:59 HOURS ET)
XYZ1 (2012_06_21 1538:14 HOURS ET)
ABCD (2012_06_21 0645:05 HOURS ET)

Just a sampling of the code that works in the other editor is:

UltraEdit.activeDocument.findReplace.replace("^([01][0-9]^)/^([0-3][0-9]^)/^([12][0-9]+^) 04:^([0-5][0-9]:[0-6][0-9]^) PM E[DS]++T", "(^3_^1_^2 16^4 ET)");

No matter what I've tried, and I've tried it for three days, I can't get any REGEX commands to work in RJ Tex Ed. Can anyone help me, PLEASE! This is the only section of the script I've worked on, with no success.

I WOULD PREFER C++ script, but JScript would be acceptable.

Thanks in advance!

User avatar
pjj
Posts: 1784
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: REGEX "Problem"

Post by pjj »

I don't think you can use regex in scripts, cf. www.rj-texted.se/Forum/viewtopic.php?f=11&t=1981&p=6997 For this matter (I don't mean regex alone) I'm bugging Rickard to give another scripting engine a go.

While with regex you would arrive at your destination faster and more easily, maybe you could inch your way (find left bracket, read 10 next characters, tokenize the string, manipulate chunks to change date format, write down)?
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus

User avatar
Rickard Johansson
Site Admin
Posts: 5988
Joined: 19 Jul 2006 14:29

Re: REGEX "Problem"

Post by Rickard Johansson »

Doesn't the "Document.ReplaceAll()" function work? Or do you need another way to do regex search, maybe in a string?

User avatar
pjj
Posts: 1784
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: REGEX "Problem"

Post by pjj »

Rickard Johansson wrote:Doesn't the "Document.ReplaceAll()" function work?
Fact is, I forgot about Document.ReplaceAll() :oops: In order to redeem myself, I tried it, but when I used

Code: Select all

Document.ReplaceAll("\d", "def", false, false, true);
it simply replaced letter d, not a digit. And when I used

Code: Select all

Document.ReplaceAll("\\d", "def", false, false, true);
RJ TE crashed (and kept crashing). Also

Code: Select all

Document.ReplaceAll("[0-9]", "def", false, false, true);
had the same result, i.e. crash. So no, it doesn't work for me :?
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus

jony33
Posts: 1
Joined: 13 Oct 2014 08:35

Re: REGEX "Problem"

Post by jony33 »

No matter what I've tried, and I've tried it for three days, I can't get any REGEX commands to work in RJ Tex Ed. Can anyone help me, PLEASE! This is the only section of the script I've worked on, with no success.

User avatar
pjj
Posts: 1784
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: REGEX "Problem"

Post by pjj »

Could you paste a script sample that doesn't work for you?
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus

Post Reply