-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtractURLsFromText.cs
More file actions
49 lines (47 loc) · 1.56 KB
/
Copy pathExtractURLsFromText.cs
File metadata and controls
49 lines (47 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ExtractURLsFromText
{
class ExtractURLsFromText
{
static void Main(string[] args)
{
Console.WriteLine("Please enter text with at least one url: ");
string input = Console.ReadLine();
string[] text = input.Split();
List<string> results = new List<string>();
foreach (string link in text)
{
if (link.Last() == '.')
{
int len=link.Length - 1;
string link1=link.Substring(0, len);
if (!results.Contains(link1) && (link1.Length > 6))
{
if (link1.Substring(0, 7) == "http://" || (link1.Substring(0, 4) == "www."))
{
results.Add(link1);
}
}
}
else
{
if (!results.Contains(link) && (link.Length > 6))
{
if (link.Substring(0, 7) == "http://" || (link.Substring(0, 4) == "www."))
{
results.Add(link);
}
}
}
}
foreach (string link in results)
{
Console.WriteLine("{0} ", link);
}
}
}
}