Page 1 of 1

Regular expl/Repl format does not work in this case, why?

Posted: Thu Oct 02, 2008 3:43 pm
by azerty
I am trying to use reg. expr and repl. format, on two almost identical test files, and the behavior is not correct (I guess).

I've posted some files here:

http://www.cyamon.com/zip/wildedit.zip

The image shows what reg.expr/repl. format I am using.

If you load the ''Working.pas'' file (in the test pane) and hit F4, you'll see that:

while ((Dir <> '') or (Drive <> '')) and (WideCanvasTextWidth(Canvas, Result) > MaxLen) do

is correcly replaced by:

while ((Dir <> '') or (Drive <> '')) and (Canvas.TextWidth(Result) > MaxLen) do
begin


Now, if you load the NotWorking.pas file, which is identical to the previous one except that there is more text /after/ the ''replacement'' point, and hit F4, then you wil get this:

while ((Dir <> '') or (Drive <> '')) and (Canvas, Result) > MaxLen) do
begin

Which is different from the previous case! I don't understand this.

Thank you for helping.

Chris

Posted: Thu Oct 02, 2008 9:15 pm
by ben_josephs
Please don't refer to screen shots; it forces those who are trying to help you to retype in your text, wasting their time and possibly introducing errors.

Select
Options | Matching options: | '.' does not match a newline character
You are selecting everything, including newlines, up to the last comma in the text. Look at what happens to the line
SizeOf(Buffer), nil);
after the replacement.

Alternatively, use
WideCanvasTextWidth\((.*?),\s*
instead of
WideCanvasTextWidth\((.*),\s*

* matches as much as possible, while *? matches as little as possible.

Posted: Fri Oct 03, 2008 1:53 am
by Bob Hansen
Please don't refer to screen shots;
Thanks ben_josephs. I had hoped to offer some help, but could not be bothered to go to another site, then jump back and forth, etc. So I chose not to get involved. Once again, you are much more tolerant than I. You are to be thanked once more.

Posted: Fri Oct 03, 2008 8:15 am
by ben_josephs
Kind words. Thank you. But I'm not so tolerant! Just uncontrollably curious. :-)

Posted: Fri Oct 03, 2008 8:58 am
by azerty
Gentlemen,

Thank you very much for the help and yes, in the future, I will not use screen shots anymore.

Chris