Forum > Packages and Libraries

RegExpr Error

(1/3) > >>

Grahame Grieve:
This program produces wrong output:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program project1; {$mode delphi }{$H+}uses  RegExpr;var  R:TRegExpr; begin  R := TRegExpr.Create;  try    R.Expression:= '^[A-Z]{2}$';    writeln(R.Exec('US'));    writeln(R.Exec('USA'));  finally    R.Free;  end;  readln;end.      
The output is


--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TRUETRUE 
But it should be TRUE and then FALSE.

Is this a bug in TRegExpr?

Lazarus 2.2.7 (rev lazarus_2_2_6-1-gada7a90f86) FPC 3.2.3 aarch64-darwin-cocoa

dseligo:
I got

--- Code: Text  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---TRUEFALSE
under FPC 3.2.2 in both Windows 11 and Debian 11.


TRon:
I got the same result as dseligo with fpc 3.2.2 and trunk at Debian bookworm.

Could it be that your results are specific to 3.2.2 fixes ?

Grahame Grieve:
Perhaps it is. I will investigate. Thanks

paweld:

--- Code: ---TRUE
FALSE
--- End code ---
Lazarus trunk + FPC 3.2.3 on Windows

Navigation

[0] Message Index

[#] Next page

Go to full version