Click here to Skip to main content
15,435,745 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I was wondering how can you implement the ability to count the amount of hyperlink URLs that it’s inside a rich text box in or c#

What I have tried:

I haven’t tried anything I need help with it
Updated 4-Jun-18 14:24pm
j snooze 4-Jun-18 17:36pm    
you're subject line and problem statement are 2 very different things. Count the amount of text or count how many URls' you have. First of I would learn a little about programming in the language you prefer because basic problem solving will be needed to become a programmer or developer. So you should try something first, search for counting text or sections of text in your preferred language. If we do it for you, we're hurting you more than helping.
Daszbin 4-Jun-18 17:47pm     CRLF
Modify the comment. Delete the comment. I am a programmer I just been trying to find an article online to figure out all I found is Regex and I much do not appreciate your snide remark‘s
j snooze 4-Jun-18 17:57pm    
Many students post their homework questions on here without trying. My remarks are not snide. You chose to read them that way. I was being honest with someone who put the comment "I haven’t tried anything I need help with it", you could have put down that all your google results showed regex examples. That means you tried something and put forth an effort. There is very little to go on here. If http or https will prefix each url you could split the string by that, but then again I don't know if you are just counting the text or counting the URL's, or counting the amount of text in each URL. Assume we know nothing of your business specs because we don't.
Daszbin 4-Jun-18 18:05pm    
Im not in school I have completed college already with my AA in computer science and will be working on Bachelors degree next year and this is a personal question for a piece of code i am working on

1 solution

Here's a way you could do it:

public int GetNumberOfLink()
   string[] links = rtb.Text.Split(' '); //Splits the text in your rtb when there's a space, and store every spilted element into a string array.
   return links.Count(); //return the number of string in the array.

then, it can be called this way:

public void SomeMethods()
   //some code
   int nbOfLinks = GetNumberOfLink();
   //some code
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900