Regex lazarus / 21-General ---------------------------------------------------------------------- BubikolRamios · 2022-06-29 23:56 Text; Quote1.       Phocides pigmalion (Cramer, 1779) foo a.   Phocides pigmalion okeechobee (Worthington, 1881) some external editor highligts 1. and 3 . line  as match to regex  '(^[0-9]+\..*$)|(^[a-z]\.+.*$)'. Expected. This repeat should go thru twice, instead goes only once and put out single line containig entire text 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   re.Expression:= '(^[0-9]+\..*$)|(^[a-z]\.+.*$)';  re.InputString:= 'the upper text';   if re.Exec(1) then  repeat    strinList.Add(re.Match[0]);  until not re.ExecNext;   The problem is in regex as I see it, if the text was Quote a foo a foo .. foo a and regex 'a' it would work, output would be 3 lines of a. Any tip? ---------------------------------------------------------------------- Roland57 · 2022-06-30 04:55 Hello! If I understand well, the problem is that ^ and $ mean "start of the input text" and "end of the input text" (and not start and end of the line). Another problem is that .* is too wide. So one possibility would be to remove ^, to replace $ with \n, and to use .*? instead of .*. 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  '([0-9]+\..*?\n)|([a-z]\.+.*?\n)' Or better (IMHO), we could use, instead of ., a more restrictive class, for example [^\n]. 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 '([0-9]+\.[^\n]*)|([a-z]\.+[^\n]*)' Hope this helps. ---------------------------------------------------------------------- AlexTP · 2022-06-30 06:44 re.ModifierM:= True (of False?). This toggles behaviour for ^ and $ metachars. ---------------------------------------------------------------------- BubikolRamios · 2022-06-30 07:54 Was pushing that forward and backward, true, false, even re.ModifierStr:='m', No effect at all. ---------------------------------------------------------------------- AlexTP · 2022-06-30 08:04 Ok, can you post small compilable example? with exact InputString. I will see it. Tell what you expect from example. ---------------------------------------------------------------------- BubikolRamios · 2022-06-30 08:22 ZIP ---------------------------------------------------------------------- BubikolRamios · 2022-06-30 08:34 Quote from: Roland57 on June 30, 2022, 06:55:33 am Another problem is that .* is too wide. OK, that. So '.*?' instead With modifierM = true; No difference '.*' to '.*?' in external highlighter, though. Thanks. ---------------------------------------------------------------------- AlexTP · 2022-06-30 09:51 Solved. You forgot to clear re.ModifierS. Must be 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   re := TRegExpr.Create();   re.ModifierM:= true;  re.ModifierS:= false;  re.Expression:= UserRegex;  re.Compile;  re.InputString:= SynEdit1.Text;   if re.Exec(1) then  repeat    showmessage('match:'#10+re.Match[0]);    //slOut.Add(re.Match[0]);  until not re.ExecNext;