Text Replace Action regexp default modifiers

When using the text replace action with regular expressions turned on I noticed that the /m modifier of the used regular expression component (TRegExpr by Andrey V. Sorokin) is by default turned off and the /s modifier is by default turned on.
(N.B. What about the /r modifier?)

This means that ^ and $ act the same as \A and \Z.

Since the (text) files used in the Text Replace action will most likely contain more than one line of text it would be nice if by default the /m modifier could be turned on and the /s modifier turned off.

Of course I can work around this by using (?m) in the search expression.

Also the TRegExpr component seems to have a bug (?) that in the following search expression the $ doesn't match the end of line but the end of text when the /s modifier is turned on.

Give the file contents:

# Set log directory
LogDirectory=

# Set internal debugging
Debug=False

The following search expression:

(?m)^LogDirectory=.*$

doesn't match the single LogDirectory line, but matches to the end of the file.

In order to work around this I have to use the following search expression:

(?m)^LogDirectory=.*?$

or

(?m)(?-s)^LogDirectory=.*$

Kind regards,

Gerrit Jan Doornink

Hi Gerrit,

Thanks for your post and your attention to detail. We are indeed using Andrey’s TRegExpr component.

Since the (text) files used in the Text Replace action will most likely contain more than one line of text it would be nice if by default the /m modifier could be turned on and the /s modifier turned off.
I agree about this. It will be changed for the next test build.


(N.B. What about the /r modifier?)
Matching Russian characters? I think this is one is best left off by default (it’s available for those who need it…)

Also the TRegExpr component seems to have a bug (?) that in the following search expression the $ doesn’t match the end of line but the end of text when the /s modifier is turned on.
This seems quite likely. We’re actually going to create a new Text Replace action very soon, and we may use as a different regular expression engine. Among other things, we want to enable the use of references in the replacement field.)

(Don’t worry, the existing action will be kept around for backwards compatibility!)

- Angus

Hi Angus,

Thanks for your reply.

Matching Russian characters? I think this is one is best left off by default (it’s available for those who need it…)

I asked because it is by default turned on in the TRegExpr component

Among other things, we want to enable the use of references in the replacement field.
Now you mention this, I just tried this in the text replace action and althought the TRegExpr component can do this using $0, $1, etc, the text replace action cannot.

(Don’t worry, the existing action will be kept around for backwards compatibility!)
Thanks

Kind regards,

Gerrit Jan

Hi Gerrit,

Yes, you’re right. There are a couple of things TRegExpr can’t do, but I’ve forgotten what they are at the moment. It is a very good component in general.

The main reason for the whole new action is that the Text Replace action has some strange quirks (when used in plain text mode) which we would like to remove, but we can’t change the existing behaviour.

I asked because it is by default turned on in the TRegExpr component

Oh, you’re right… I hadn’t noticed. :).
Regards,

Angus