Recent

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

Edson

  • Hero Member
  • *****
  • Posts: 1301
[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.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

lucamar

  • Hero Member
  • *****
  • Posts: 4219
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? :o

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

Edson

  • Hero Member
  • *****
  • Posts: 1301
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.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
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 »
Specialize a type, not a var.

Edson

  • Hero Member
  • *****
  • Posts: 1301
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.  :-X, and it was working for a long time in my previous versions of Lazarus   :(.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • 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

  • Sr. Member
  • ****
  • Posts: 299
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 !
greetings Maik

Windows 10,
- Lazarus 2.2.6 (stable) + fpc 3.2.2 (stable)
- Lazarus 2.2.7 (fixes) + fpc 3.3.1 (main/trunk)

Edson

  • Hero Member
  • *****
  • Posts: 1301
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.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

 

TinyPortal © 2005-2018