search regex [solved] lazarus / 49-FPSpreadsheet ---------------------------------------------------------------------- rnervi · 2025-09-01 05:52 I need to find this case in a sheet: is good if inside two slash there are 3 chars  e.g. "AA/ABC/222" so I built a regex: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i MySearchParams.SearchText := '~\/[a-z]{3}\/~gmi';MySearchParams.Options := [soEntireDocument, soCompareEntireCell, soRegularExpr];MySearchParams.Within := swWorkbook; that in testfield (regex) it works but seems ignored in the  IF FindFirst(MySearchParams, foundWorksheet, foundRow, foundCol) THEN (no match) any ideas ? ty ---------------------------------------------------------------------- wp · 2025-09-01 08:37 FPSpreadsheet uses the regex coming with FPC (unit RegExpr), and that does not find it: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses   RegExpr;   procedure RunRegEx;  var    re: TRegExpr;  begin    re := TRegExpr.Create('~\/[a-z]{3}\/~gmi');    if re.Exec('AA/ABC/222') then    begin      WriteLn(re.Match[1]);      while re.ExecNext do    begin        WriteLn(re.Match[1]);      end;    end else      WriteLn('-- not found --');    re.Free;  end;  begin  RunRegEx;  ReadLn;end. ---------------------------------------------------------------------- Zvoni · 2025-09-01 08:58 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;{$mode objfpc}{$H+}Uses Sysutils, Classes, regexpr;Var  r:TRegExpr;  b:Boolean; begin  r:=TRegexpr.Create;  r.Expression:='\/[a-z]{3}\/';  r.ModifierG:=True;  r.ModifierI:=True;  r.ModifierM:=True;  r.InputString:='AA/ABC/222';  b:=r.Exec;  IF b Then Writeln('Found') Else Writeln('not found');  Readln;end.Writes "Found" Conclusion: Leave out the Tildes, and set the Modifiers as shown EDIT: I could circumvent the "i" and "m" Modifiers, but haven't found how to avoid the "g"-Modifier Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Project1;{$mode objfpc}{$H+}Uses Sysutils, Classes, regexpr;Var  r:TRegExpr;  b:Boolean; begin  r:=TRegexpr.Create;  r.Expression:='(?i)(?m)\/[a-z]{3}\/';  r.ModifierG:=True;  //r.ModifierI:=True;  //r.ModifierM:=True;  r.InputString:='AA/ABC/222';  b:=r.Exec;  IF b Then Writeln('Found') Else Writeln('not found');  Readln;end.Returns "Found" EDIT2: re "g"-Modifier Seems there is no "Pattern"-Modifier for "g". It's just the difference finding the first Match, or going through a loop finding all OTOH, i wouldn't know whats sense it makes to find all occurences IN ONE GO in a spreadsheet. It's always been "stop after first match", and "continue search" if it's not the match you are looking for ---------------------------------------------------------------------- Thaddy · 2025-09-01 09:49 I used the simpler /[A-Za-z]{3}\/ Dunno if that is enough ---------------------------------------------------------------------- Zvoni · 2025-09-01 10:22 Quote from: Thaddy on September 01, 2025, 11:49:19 amI used the simpler /[A-Za-z]{3}\/ Dunno if that is enough You'd still need the modifier for Multiline my sample above works with TRegExpr ---------------------------------------------------------------------- rnervi · 2025-09-01 18:43 ty to all will try and let know results @Thaddy  : works like a charm