View Issue Details

IDProjectCategoryView StatusLast Update
0034429FPCPackagespublic2018-10-20 12:12
ReporterAndrey Sorokin Assigned ToMichael Van Canneyt  
Status resolvedResolutionfixed 
Target Version3.2.0Fixed in Version3.3.1 
Summary0034429: Different esc-sequences processing in regular expression and substitution string in RegExpr.Replace
DescriptionIn regular expression RegExpr treats '\n' as #$a, but in substitution string
(Replace function) by default '\n' treated platform-dependent.
So for windows this is #$d#$a.
Steps To ReproduceReplaceRegExpr('\n', 'abc'#$D#$A'def', '\n', True)
returns abc'#$D#$D#$A'def
Additional InformationI created pull-request in github but do not see how to send it to SVN

I implemented in Replace function the same esc-sequences processing as in main regular expression parser.

And switched off {$DEF UseOsLineEndOnReplace}.

For old behaviour of '\n' in substitution strings you have to uncomment {$DEF UseOsLineEndOnReplace}

TagsNo tags attached.
Fixed in Revision39993
Attached Files


Maxim Ganetsky

2018-10-17 12:01

reporter   ~0111440

This issue belongs to FPC project. Moving.


2018-10-17 22:24

reporter   ~0111445

The pull request as a patch:

CudaText man

2018-10-18 07:12

reporter   ~0111448

maybe you can fix this issue too?
Thanks for your work on RegExpr.

Andrey Sorokin

2018-10-18 13:42

reporter   ~0111453

I am not sure we have to fit it - wrote answer in the ticket.

Michael Van Canneyt

2018-10-20 12:11

administrator   ~0111482

I have done this differently.

The define is now a property of the RE object.

We should not expect people to recompile the unit if they want different behaviour, moreover people may want different behaviour depending on the situation:
for example in a text editor you may want to be able to set this depending on the line-ending setting of the current file in the editor.

I also converted the tests to unit tests.

Thanks for the patch !

Michael Van Canneyt

2018-10-20 12:12

administrator   ~0111483

Forgot to add, the default is to use OS line ending, for backwards compatibility.

Issue History

Date Modified Username Field Change
2018-10-17 08:51 Andrey Sorokin New Issue
2018-10-17 12:01 Maxim Ganetsky Note Added: 0111440
2018-10-17 12:01 Maxim Ganetsky Project Packages => FPC
2018-10-17 22:24 cordylus Note Added: 0111445
2018-10-18 07:12 CudaText man Note Added: 0111448
2018-10-18 13:42 Andrey Sorokin Note Added: 0111453
2018-10-20 10:43 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-10-20 10:43 Michael Van Canneyt Status new => assigned
2018-10-20 12:11 Michael Van Canneyt Fixed in Revision => 39993
2018-10-20 12:11 Michael Van Canneyt Note Added: 0111482
2018-10-20 12:11 Michael Van Canneyt Status assigned => resolved
2018-10-20 12:11 Michael Van Canneyt Fixed in Version => 3.3.1
2018-10-20 12:11 Michael Van Canneyt Resolution open => fixed
2018-10-20 12:11 Michael Van Canneyt Target Version => 3.2.0
2018-10-20 12:12 Michael Van Canneyt Note Added: 0111483