### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: [Solved] What happens to TRegExpr?  (Read 562 times)

#### Edson

• Hero Member
• Posts: 1124
##### [Solved] What happens to TRegExpr?
« on: November 24, 2020, 06:53:14 pm »
I'm having problems with a function using TRegExpr, and FAIK I haven't modified my code  I just have updated my Lazarus to 2.0.10.

I read there are some bug in TRegExpr. What could be the solution?

« Last Edit: November 25, 2020, 03:52:59 am by Edson »
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

#### lucamar

• Hero Member
• Posts: 3428
##### Re: What happens to TRegExpr?
« Reply #1 on: November 24, 2020, 07:20:22 pm »
You do realize it's close to impossible to propose a solution without knowing what is the problem (with as much detail as you can gather), don't you?

C'mon, Edson, you're not a newbie anymore ...
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!)
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

#### Edson

• Hero Member
• Posts: 1124
##### Re: What happens to TRegExpr?
« Reply #2 on: November 24, 2020, 07:30:28 pm »
I was expecting for a patch or something like that. No problem. Maybe I'm wrong.

Anyway my code is something like this:

Code: Pascal  [Select][+][-]
1.
2.   re := TRegExpr.Create;
3.   re.Expression := '^(\S+)\x20+(\d+)\x20+(\w+)\x20+(\w+)\x20+(\d+)\x20+'+
4.   '(\w{3}\x20+\d+\x20+\S+|\d+\x20+\w{3}\x20+\S+)\x20+(.+)';
5.   ...
6.   if (re.Exec(lin)) then begin
7.   ...
8.

And it fails with this string:

Code: Pascal  [Select][+][-]
1. drwxr-xr-x   2 root   root  4096 Sep 24 06:01 bin

Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

• Hero Member
• Posts: 10684
##### Re: What happens to TRegExpr?
« Reply #3 on: November 24, 2020, 07:35:07 pm »
Rather than bug(s), there are some proposals for extensions and I believe some patches are submitted.
The current code in 3.2.0 and before is very stable. It is just not feature complete in border cases. (back propagation and the likes)
Note you can not simply copy any regexpr from other languages, because you need to adjust some expressions to Pascal escapes.

Your fail string has nothing to do with TRegExpr. It is not even a fail string.
« Last Edit: November 24, 2020, 08:10:04 pm by Thaddy »

#### Edson

• Hero Member
• Posts: 1124
##### Re: What happens to TRegExpr?
« Reply #4 on: November 24, 2020, 09:01:49 pm »
Note you can not simply copy any regexpr from other languages, because you need to adjust some expressions to Pascal escapes.

Your fail string has nothing to do with TRegExpr. It is not even a fail string.

Well I haven't copied this regex from other languages. I made this specially for TRegExpr of Free Pascal.  , and it was working for a long time in my previous versions of Lazarus   .
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

#### marcov

• Global Moderator
• Hero Member
• Posts: 9014
• FPC developer.
##### Re: What happens to TRegExpr?
« Reply #5 on: November 24, 2020, 10:06:34 pm »
3.2.0 doesn't match, 3.3.1 does match

(edited, 3.1.1->3.3.1)
« Last Edit: November 24, 2020, 11:30:20 pm by marcov »

#### sstvmaster

• Full Member
• Posts: 190
##### Re: What happens to TRegExpr?
« Reply #6 on: November 24, 2020, 11:27:02 pm »
This little demo uses regexpr unit from trunk, it is included in zip.

! It uses RichMemo !
Windows 10 (64 bit)
Lazarus: 2.0.10 / Trunk x32

#### Edson

• Hero Member
• Posts: 1124
##### Re: What happens to TRegExpr?
« Reply #7 on: November 25, 2020, 03:52:37 am »
Thanks very much for the answers.

@sstvmaster the Regexpr unit included in the zip, works perfectly.
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8