Page 1 of 1

REGEX "Problem"

Posted: 02 Jun 2013 16:49
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!

Re: REGEX "Problem"

Posted: 02 Jun 2013 17:48
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)?

Re: REGEX "Problem"

Posted: 03 Jun 2013 12:59
by Rickard Johansson
Doesn't the "Document.ReplaceAll()" function work? Or do you need another way to do regex search, maybe in a string?

Re: REGEX "Problem"

Posted: 04 Jun 2013 08:20
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 :?

Re: REGEX "Problem"

Posted: 13 Oct 2014 08:39
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. the customer does not have to buy any membership plan

Re: REGEX "Problem"

Posted: 13 Oct 2014 09:47
by pjj
Could you paste a script sample that doesn't work for you?