[SOLVED] SQLite open link lazarus / 16-Databases ---------------------------------------------------------------------- Pe3s · 2023-07-15 19:31 Hello, how can I improve the code so that ShellExecute works for addresses without http:// ? 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 var Link: String;beginif ZQuery2.RecordCount = 0 then Exit;  Link := ZQuery2.FieldByName('Link').AsString;  ShellExecute(Handle, 'open', PChar(Link), nil, nil, SW_SHOW);end; ---------------------------------------------------------------------- TRon · 2023-07-15 19:46 Quote from: Pe3s on July 15, 2023, 09:31:22 pmHello, how can I improve the code so that ShellExecute works for addresses without http:// ? 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 var Link: String;beginif ZQuery2.RecordCount = 0 then Exit;  Link := ZQuery2.FieldByName('Link').AsString;  if not Link.StartsWith('http://') then Link := 'http://' + Link;  ShellExecute(Handle, 'open', PChar(Link), nil, nil, SW_SHOW);end; ? ---------------------------------------------------------------------- Pe3s · 2023-07-16 07:33 @TRon, Thank you ---------------------------------------------------------------------- Zvoni · 2023-07-17 06:24 Or use regex https://regex101.com/r/vsumW6/1 catches both: http and https ---------------------------------------------------------------------- Pe3s · 2023-07-22 10:09 Thank you ---------------------------------------------------------------------- TRon · 2023-07-22 10:22 @Zvoni: Though my solution is far from perfect as proofed by your examples, that is one heck of an expression and still fails when the protocol name has a capital letter. Thus casting to low or high for checking the protocol is preferred (I know that can (easily) be added to the expression as well  ). If you really want to do it properly then ParseURI and EncodeURI is imho far more understandable (though I do admit that when using RE's is something that you do every day you probably read/write it as a normal person would read/write text is his/her native tongue -> I honestly can't). ---------------------------------------------------------------------- Zvoni · 2023-07-22 10:49 Quote from: TRon on July 22, 2023, 12:22:57 pm@Zvoni: Though my solution is far from perfect as proofed by your examples, that is one heck of an expression and still fails when the protocol name has a capital letter. Thus casting to low or high for checking the protocol is preferred (I know that can (easily) be added to the expression as well  ).Or switch to case insensitive … ---------------------------------------------------------------------- TRon · 2023-07-22 11:41 Quote from: Zvoni on July 22, 2023, 12:49:48 pmOr switch to case insensitive … Rrright. Forgot about that one