Used with #. Parsing text from the site has several options:

Var 1

FG654HGFH = FGJ6DJ131HDFHSFSGRv = http://site1.ru/jfd6oin/bfg654ryan-knight%3Futm_/te654DDFm%3D%26cid%3D1065

Var 2

dfg6546sdgs = dgd646ttrdhx32gfh = http://site2.com/nhgh65h/bfg654ryan-kng654fight%/etesd6s5d4sdgs654DDFm%3D%2

Var 3

dfh6565jrtu = u63mb2,1CjyttmKYU = http://site3.net/nsdxch6/bfg654vcvn-knsdsffbnht%/sdg987bn,uio98ofp64utrury
Special conditions:

  • domain site (1,2,3, ...) - adopted conditionally. Domain name does not have any trends and is always different;
  • http: // maybe https: //

How to clear the text so that it remains, for example for http://site1.ru :

- http://site1.ru

or

  • site1.ru

or

  • Site1

At the same time without being attached to the domain name, since domain names are not known.

1 answer 1

As an option : )

  String str = @"FG654HGFH=FGJ6DJ131HDFHSFSGRv=http://site1.ru/jfd6oin/bfg654ryan-knight%3Futm_/te654DDFm%3D%26cid%3D1065"; str = str.Substring(str.IndexOf("://") + "://".Length); str = str.Substring(0, str.IndexOf("/")); Console.WriteLine(str); 

Displays site1.ru

As an answer, the regular option from rdom :

  String str = @"FG654HGFH=FGJ6DJ131HDFHSFSGRv=http://site1.ru/jfd6oin/bfg654ryan-knight%3Futm_/te654DDFm%3D%26cid%3D1065"; var regex = new System.Text.RegularExpressions.Regex(@"http[s]?://\w+([.]\w+)+"); str = regex.Matches(str)[0].ToString(); Console.WriteLine(str); 

Displays: http://site1.ru

  • the answer from one regular season is not serious, so it’s hanging in the comments, you can add it to yours , I don’t feel sorry =) - rdorn