Re: Extract sub string from a string

2020-11-09 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Monday, 9 November 2020 at 18:55:44 UTC, Ali Çehreli wrote: On 11/9/20 9:53 AM, k2aj wrote: > string text = "welcome2worldinfo"; > string hg = toUpper(text[0..7] ~ "-" ~ text[7..8] ~ "-" ~ text[8..13]); If those concatenations with the ~ operators prove to be costly at runtime, the followin

Re: Extract sub string from a string

2020-11-09 Thread Vino via Digitalmars-d-learn
On Monday, 9 November 2020 at 18:55:44 UTC, Ali Çehreli wrote: On 11/9/20 9:53 AM, k2aj wrote: > string text = "welcome2worldinfo"; > string hg = toUpper(text[0..7] ~ "-" ~ text[7..8] ~ "-" ~ text[8..13]); If those concatenations with the ~ operators prove to be costly at runtime, the followin

Re: Extract sub string from a string

2020-11-09 Thread Ali Çehreli via Digitalmars-d-learn
On 11/9/20 9:53 AM, k2aj wrote: > string text = "welcome2worldinfo"; > string hg = toUpper(text[0..7] ~ "-" ~ text[7..8] ~ "-" ~ text[8..13]); If those concatenations with the ~ operators prove to be costly at runtime, the following range expression may be faster because it does not allocate a

Re: Extract sub string from a string

2020-11-09 Thread k2aj via Digitalmars-d-learn
On Monday, 9 November 2020 at 16:00:28 UTC, Vino wrote: Hi All, Request your help on how to extract sub string from a string, below is an example in PHP, need your help on how to do the same in D. $text = "welcome2worldinfo"; $hg = strtoupper(substr($text , 0, 7).'-'

Re: Extract sub string from a string

2020-11-09 Thread Виталий Фадеев via Digitalmars-d-learn
On Monday, 9 November 2020 at 16:00:28 UTC, Vino wrote: Hi All, Request your help on how to extract sub string from a string, below is an example in PHP, need your help on how to do the same in D. $text = "welcome2worldinfo"; $hg = strtoupper(substr($text , 0, 7).'-'

Extract sub string from a string

2020-11-09 Thread Vino via Digitalmars-d-learn
Hi All, Request your help on how to extract sub string from a string, below is an example in PHP, need your help on how to do the same in D. $text = "welcome2worldinfo"; $hg = strtoupper(substr($text , 0, 7).'-'.substr($text, 7, 1).'-'.substr($text, 8