Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5849171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:57:44+00:00 2026-05-22T12:57:44+00:00

Lets say I have a String: Go to this page: http://mysite.com/?page=1 , and I

  • 0

Lets say I have a String: Go to this page: http://mysite.com/?page=1 , and I have a string page. I would like to create a function like so:

MyBoolean := IsLink('Go to this page: http://mysite.com/?page=1','page',sLink); 
// sLink is a Var, so it would return http://mysite.com/?page=1

Basically it is supposed to check if the word “page” is part of a link or not.

However I just can’t figure it out. Any tips?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:57:44+00:00Added an answer on May 22, 2026 at 12:57 pm

    You could do something like

    function GetLinkContaining(const Str, SubStr: string; out URL: string): boolean;
    const
      ValidURLSpecialChars = ['.', ':', '/', '?', '=', '&', '%'];
      Prefixes: array[0..4] of string = ('http://', 'https://', 'ftp://', 'mailto:',
        'www.');
    
      function IsValidURLChar(const Char: char): boolean;
      begin
        result := IsLetterOrDigit(Char) or (Char in ValidURLSpecialChars);
      end;
    
    var
      SubStrPos: integer;
      Start, &End: integer;
      i: Integer;
      URLBegin: integer;
    begin
      result := false;
    
      URLBegin := 0;
      for i := low(Prefixes) to High(Prefixes) do
      begin
        URLBegin := Pos(Prefixes[i], Str);
        if URLBegin > 0 then
          break;
      end;
      if URLBegin = 0 then Exit(false);
    
      SubStrPos := PosEx(SubStr, Str, URLBegin);
      if SubStrPos = 0 then Exit(false);
    
      Start := SubStrPos;
      for i := SubStrPos - 1 downto 1 do
        if IsValidURLChar(Str[i]) then
          dec(Start)
        else
          break;
      &End := SubStrPos + length(SubStr);
      for i := SubStrPos + length(SubStr) to length(Str) do
        if IsValidURLChar(Str[i]) then
          inc(&End)
        else
          break;
      URL := Copy(Str, Start, &End - Start);
      result := true;
    end;
    

    To test it:

    procedure TForm1.FormCreate(Sender: TObject);
    var
      s: string;
    begin
      if GetLinkContaining('Go to this page: http://mysite.com/?page=1 (right now!)',
        'page', s) then
        ShowMessage(s);
      if GetLinkContaining('This is my favourite site (www.bbc.co.uk).', 'bbc', s) then
        ShowMessage(s);        
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have a string COLIN. The numeric value of this string would
Lets say I have an array like this: string [] Filelist = ... I
Let's say I have a PHP Model-View-Controller framework that maps an address like http://example.com/admin/posts/edit/5
Lets say I have a class like this in class1.vb: Public Class my_class Public
Lets say I have this XML file: <weather> <temp>24.0</temp> <current-condition iconUrl=http://....>Sunny</current-condition> </weather> I'm trying
So let's say I have a in page function: <img src=someImage.jpg onclick=doSomething(this.id) id=someVar alt=blah
How do you split a string? Lets say i have a string dog, cat,
Lets say I have the following code: abstract class Animal case class Dog(name:String) extends
Lets say I have a Dictionary object: Dictionary myDictionary<int, SomeObject> = new Dictionary<string, SomeObject>();
I have a method lets say: private static String drawCellValue( int maxCellLength, String cellValue,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.