to transform a list of URLs into pretty domain names

Perfecto

Client
Регистрация
06.08.2013
Сообщения
94
Благодарностей
4
Баллы
8

zortexx

Client
Регистрация
19.09.2011
Сообщения
2 520
Благодарностей
1 223
Баллы
113

orka13

Client
Регистрация
07.05.2015
Сообщения
2 167
Благодарностей
2 169
Баллы
113
C# code (including Zenno ToUpper Method ):
Код:
string url = project.Variables["url"].Value; // url = http://zennolab.com/discussion/
url = new Uri(url).Host; // returns only Host (zennolab.com)

// performs to upper operation for first letters (returns Zennolab.Com)
string firstLettersToUpper = Macros.TextProcessing.ToUpper(url, "FirstLetters");

// performs to upper operation for first letter (returns Zennolab.com)
string firstLetterToUpper = Macros.TextProcessing.ToUpper(url, "FirstLetter");

return firstLetterToUpper; // or replace "firstLetterToUpper" with "firstLettersToUpper"
 
Последнее редактирование:
  • Спасибо
Реакции: zortexx

zortexx

Client
Регистрация
19.09.2011
Сообщения
2 520
Благодарностей
1 223
Баллы
113
upload_2017-10-2_22-42-47.png
 

Вложения

Последнее редактирование:
  • Спасибо
Реакции: Perfecto

Perfecto

Client
Регистрация
06.08.2013
Сообщения
94
Благодарностей
4
Баллы
8
C# code (include Zenno ToUpper Method ):
Код:
string url = project.Variables["url"].Value; // url = http://zennolab.com/discussion/
url = new Uri(url).Host; // returns only Host (zennolab.com)

// performs to upper operation for first letters (returns Zennolab.Com)
string firstLettersToUpper = Macros.TextProcessing.ToUpper(url, "FirstLetters");

// performs to upper operation for first letter (returns Zennolab.com)
string firstLetterToUpper = Macros.TextProcessing.ToUpper(url, "FirstLetter");

return firstLetterToUpper; // or replace "firstLetterToUpper" with "firstLettersToUpper"
Thanks!
I tried removing the "www." when there are. with this code but it does not work:
Код:
string url = project.Variables["URL"].Value; // url = http://zennolab.com/discussion/
url = new Uri(url).Host; // returns only Host (zennolab.com)

// replace "this" in string to "new value"
string newString = Macros.TextProcessing.Replace(url, "www.", "", "Text", "All");

// performs to upper operation for first letters (returns Zennolab.Com)
string firstLettersToUpper = Macros.TextProcessing.ToUpper(url, "FirstLetters");

// performs to upper operation for first letter (returns Zennolab.com)
string firstLetterToUpper = Macros.TextProcessing.ToUpper(url, "FirstLetter");

return firstLetterToUpper; // or replace "firstLetterToUpper" with "firstLettersToUpper"
Is there a way to returns only Host without going through C # code?
 

zortexx

Client
Регистрация
19.09.2011
Сообщения
2 520
Благодарностей
1 223
Баллы
113

orka13

Client
Регистрация
07.05.2015
Сообщения
2 167
Благодарностей
2 169
Баллы
113
Thanks!
I tried removing the "www." when there are. with this code but it does not work:
Код:
string url = project.Variables["URL"].Value; // url = http://zennolab.com/discussion/
url = new Uri(url).Host; // returns only Host (zennolab.com)

// replace "this" in string to "new value"
string newString = Macros.TextProcessing.Replace(url, "www.", "", "Text", "All");

// performs to upper operation for first letters (returns Zennolab.Com)
string firstLettersToUpper = Macros.TextProcessing.ToUpper(url, "FirstLetters");

// performs to upper operation for first letter (returns Zennolab.com)
string firstLetterToUpper = Macros.TextProcessing.ToUpper(url, "FirstLetter");

return firstLetterToUpper; // or replace "firstLetterToUpper" with "firstLettersToUpper"
Is there a way to returns only Host without going through C # code?
Код:
string url = project.Variables["url"].Value; // url = http://zennolab.com/discussion/
url = new Uri(url).Host; // returns only Host (zennolab.com)

// replace "www." at the beginning of the line to ""
url = System.Text.RegularExpressions.Regex.Replace(url, @"^www\.", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);

// performs to upper operation for first letters (returns Zennolab.Com)
string firstLettersToUpper = Macros.TextProcessing.ToUpper(url, "FirstLetters");

// performs to upper operation for first letter (returns Zennolab.com)
string firstLetterToUpper = Macros.TextProcessing.ToUpper(url, "FirstLetter");

return firstLetterToUpper; // or replace "firstLetterToUpper" with "firstLettersToUpper"
 
  • Спасибо
Реакции: Perfecto

Perfecto

Client
Регистрация
06.08.2013
Сообщения
94
Благодарностей
4
Баллы
8

zortexx

Client
Регистрация
19.09.2011
Сообщения
2 520
Благодарностей
1 223
Баллы
113

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)