Forum > General

RegExpr freeze

(1/2) > >>

Fahmy Rofiq:
Please help,
This code freeze my app.


--- 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";}};} ---  R := TRegExpr.Create;  try    R.Expression:= '.+ (.+)\.(.+) GAGAL\.(.+)\. Sa.+ (.+) @';    R.InputString:= 'Rp.20.020 @21/11 18:35:04 =Sukses'#$0A'I25.085785721252 Rp.24.950 @21/11 18:56:58 =Sukses'#$0A'SP100.082164017112 Rp.96.675 @21/11 19:12:15 =Sukses'#$0A'CEKPLNP.32104710689 Rp.0 @21/11 19:16:45 =Sukses'#$0A'PLNS20.32104710689 Rp.20.020 @21/11 19:16:58 =Sukses'#$0A'HOTSP2.087788450220 Rp.11.150 @21/11 19:45:42 =Sukses'#$0A'I50.085783334145 Rp.49.300 @21/11 19:55:46 =Gagal'#$0A'IP50.085783334145 Rp.48.825 @21/11 19:57:05 =Sukses'#$0A'X10.087889018070 Rp.10.750 @21/11 19:58:32 =Sukses'#$0A'VIFI3.085620102211 Rp.24.300 @21/11 20:10:36 =Sukses'#$0A'CEKPLNP.511820312863 Rp.0 @21/11 20:33:24 =Sukses'#$0A'PLNS20.511820312863 Rp.20.020 @21/11 20:33:31 =Sukses'#$0A'SP10.082231983818 Rp.10.310 @21/11 20:37:08 =Sukses'#$0A'VIFI10.085620375811 Rp.47.850 @21/11 20:38:04 =Sukses'#$0A'IDFI10.085785674040 Rp.47.250 @21/11 20:39:31 =Sukses'#$0A'AXDP1.083176152220 Rp.12.800 @21/11 20:40:16 =Sukses'#$0A'VAM1.083821032311 Rp.7.700 @21/11 21:03:27 =Sukses'#$0A'VSFN6.088821060811 Rp.28.200 @21/11 21:06:13 =Sukses'#$0A'CEKPLNP.14289371883 Rp.0 @21/11 21:10:47 =Sukses'#$0A'PLNS20.14289371883 Rp.20.020 @21/11 21:10:55 =Sukses'#$0A'I20.085736474245 Rp.19.920 @21/11 21:12:09 =Sukses'#$0A'I5.085707312468 Rp.5.850 @21/11 21:14:06 =Sukses'#$0A'SP25.081330256164 Rp.24.865 @21/11 21:15:22 =Sukses'#$0A'SP10.081330256164 Rp.10.310 @21/11 21:15:57 =Sukses'#$0A'CEKPLNP.511820710359 Rp.0 @21/11 21:27:45 =Sukses'#$0A'PLNS50.511820710359 Rp.50.020 @21/11 21:27:56 =Sukses'#$0A'X5.083834182370 Rp.5.810 @21/11 21:29:25 =Sukses'#$0A'CEKPLNP.56210024081 Rp.0 @21/11 21:40:53 =Sukses'#$0A'PLNS20.56210024081 Rp.20.020 @21/11 21:41:11 =Sukses'#$0A'MAP4.0895366492293 Rp.3.500 @21/11 21:54:13 =Sukses'#$0A'SP10.082169403831 Rp.10.310 @21/11 21:56:04 =Sukses'#$0A'AIGO8.083821570311 Rp.56.850 @21/11 21:57:09 =Sukses'#$0A'X10.087751660354 Rp.10.750 @21/11 22:03:24 =Sukses'#$0A'SP25.085334597049 Rp.24.865 @21/11 22:08:43 =Sukses'#$0A'SP15.08133808550 Rp.14.880 @21/11 22:10:45 =Gagal'#$0A'SP15.081338808550 Rp.14.880 @21/11 22:11:16 =Sukses'#$0A'SM10.088996450900 Rp.9.950 @21/11 22:49:53 =Sukses'#$0A'SP10.081286394373 Rp.10.310 @21/11 22:52:38 =Gagal'#$0A'S10.081286349373 Rp.10.500 @21/11 22:53:17 =Sukses'#$0A'T5.0895335171927 Rp.5.285 @21/11 23:22:12 =Sukses'#$0A'CEKPLNP.32021831857 Rp.0 @21/11 23:41:41 =Sukses'#$0A'PLNS20.32021831857 Rp.20.020 @21/11 23:41:46 =Sukses'#$0A'CEKPLNP.32021831857 Rp.0 @22/11 02:36:50 =Sukses'#$0A'SP10.081330959088 Rp.10.310 @22/11 07:01:11 =Sukses'#$0A'I25.085748608750 Rp.24.950 @22/11 08:14:56 =Sukses'#$0A'SP25.081331109400 Rp.24.865 @22/11 08:17:42 =Sukses'#$0A'TRDA22.089676907229 Rp.59.250 @22/11 08:39:09 =Sukses'#$0A'SP20.081233829042 Rp.19.975 @22/11 10:22:35 =Sukses'#$0A'I10.085762218826 Rp.10.775 @22/11 10:38:33 =Sukses'#$0A'VXL8.087810385711 Rp.38.100 @22/11 10:39:12 =Sukses'#$0A'TDF1.082133868564 Rp.14.000 @22/11 11:06:02 =Sukses'#$0A'CEKPLNP.14414637059 Rp.0 @22/11 10:58:27 =Sukses'#$0A'PLNS20.14414637059 Rp.20.020 @22/11 10:58:43 =Sukses'#$0A'VIY7.085611331911 Rp.10.200 @22/11 11:33:24 =Sukses'#$0A'VIFI2.085611332411 Rp.15.000 @22/11 11:33:39 =Sukses'#$0A'SP10.081352326723 Rp.10.310 @22/11 11:46:50 =Sukses'#$0A'IP15.085745822016 Rp.15.000 @22/11 12:12:13 =Sukses'#$0A'HOTSP3.087751632740 Rp.8.575 @22/11 12:14:27 =Sukses'#$0A'I10.085608369109 Rp.10.775 @22/11 12:27:17 =Sukses'#$0A'I10.085604334516 Rp.10.775 @22/11 12:26:56 =Sukses'#$0A'VIFI3.085612242411 Rp.24.300 @22/11 12:24:29 =Sukses'#$0A'I10.085730194383 Rp.10.775 @22/11 12:51:55 =Sukses'#$0A'SM50.08883685535 Rp.49.000 @22/11 12:55:56 =Sukses'#$0A'XA15.081997976808 Rp.14.850 @22/11 13:39:52 =Sukses'#$0A'I5.085730384822 Rp.5.850 @22/11 13:53:08 =Sukses'#$0A'VMJT8.085213532511 Rp.56.000 @22/11 13:53:49 =Sukses'#$0A'CEKPLNP.14005491643 Rp.0 @22/11 13:56:00 =Sukses'#$0A'PLNS100.14005491643 Rp.100.020 @22/11 13:56:16 =Sukses'#$0A'CEKPLNP.56210026474 Rp.0 @22/11 16:40:58 =Sukses'#$0A'PLNS20.56210026474 Rp.20.020 @22/11 16:41:10 =Sukses'#$0A'PLNS20.32021831857 Rp.20.020 @22/11 16:59:22 =Sukses'#$0A'CEKPLNP.32169475319 Rp.0 @22/11 17:15:34 =Sukses'#$0A'PLNS20.32169475319 Rp.20.020 @22/11 17:15:50 =Sukses'#$0A'CEKPLNP.32169475285 Rp.0 @22/11 17:16:02 =Sukses'#$0A'PLNS20.32169475285 Rp.20.020 @22/11 17:16:10 =Sukses'#$0A'X10.081997976808 Rp.10.750 @22/11 17:24:11 =Sukses'#$0A'AIGO1.083817332611 R';    R.Exec;  finally    R.Free;  end;

Roland57:
Hello! What would be surprising is if the function managed to find a result. Your expression is too vague. Concretely, there are too many dots. You should not use the dot, or very little. You should use more determined classes, like '\d' or '\w'. And also more determined operators for the number of characters, like '{n,n}'. Otherwise you give to the computer an impossible task. Do you see what I mean?

If you tell us which substring you try to capture, we could help you to find a more efficient expression.

Fahmy Rofiq:
I dont expect a result from that input string.

Expression '.+ (.+)\.(.+) GAGAL\.(.+)\. Sa.+ (.+) @'
is for input like '@REFID: #TRXID:58935149 TDF1.082133868564 GAGAL. . Saldo 817.794 @12:08 * KOMPLAIN MAX H+7'
i can get: 'TDF1','082133868564',' ','817.794'

But sometimes i get unexpected input from server like example above.
From that example i expect it will result FALSE for R.Exec but its not.
The function never return.

Sorry for my English, not my native language.

MarkMLl:
I'm troubled by those embedded newlines. I suspect you also need to check whether your match is case-insensitive.

MarkMLl

Roland57:

--- Quote from: Fahmy Rofiq on November 25, 2021, 08:22:17 am ---Expression '.+ (.+)\.(.+) GAGAL\.(\s+)\. Sa.+ (.+) @'
is for input like '@REFID: #TRXID:58935149 TDF1.082133868564 GAGAL. . Saldo 817.794 @12:08 * KOMPLAIN MAX H+7'
i can get: 'TDF1','082133868564',' ','817.794'

--- End quote ---

So (if I correctly understood your problem) your expression should be something like this:


--- 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";}};} ---begin  R := TRegExpr.Create;  try    R.Expression := '(\w\w\w\d)\.(\d{12}) GAGAL\.(\s+)\. Sa\w+ (\d{3}\.\d{3}) @';    R.InputString := '@REFID: #TRXID:58935149 TDF1.082133868564 GAGAL. . Saldo 817.794 @12:08 * KOMPLAIN MAX H+7';    if R.Exec then    begin      WriteLn('[', R.Match[1], ']');      WriteLn('[', R.Match[2], ']');      WriteLn('[', R.Match[3], ']');      WriteLn('[', R.Match[4], ']');    end;  finally    R.Free;  end;end.
Do you see the idea?

Navigation

[0] Message Index

[#] Next page

Go to full version