Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 4 March 2022 at 02:36:35 UTC, Ali Çehreli wrote: I assumed it would generate separate integers 123 and 456. I started to implement a range with findSkip, findSplit, and friends but failed. :/ I worked on it a little. I guess it's better that way. But I didn't think about negati

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 4 March 2022 at 02:36:35 UTC, Ali Çehreli wrote: On 3/3/22 13:03, H. S. Teoh wrote: >string s = "blahblah123blehbleh456bluhbluh"; >assert(result == 123456); I assumed it would generate separate integers 123 and 456. I started to implement a range with findSkip, findSplit, a

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread Ali Çehreli via Digitalmars-d-learn
On 3/3/22 13:03, H. S. Teoh wrote: >string s = "blahblah123blehbleh456bluhbluh"; >assert(result == 123456); I assumed it would generate separate integers 123 and 456. I started to implement a range with findSkip, findSplit, and friends but failed. :/ Ali

Re: How to use ImportC?

2022-03-03 Thread bachmeier via Digitalmars-d-learn
On Friday, 4 March 2022 at 01:30:00 UTC, Leonardo wrote: Thanks but not worked here. ``` [leonardo@leonardo-pc dimportc]$ dmd --version DMD64 D Compiler v2.098.1 Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved written by Walter Bright [leonardo@leonardo-pc dimportc]$

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 3 March 2022 at 20:23:14 UTC, forkit wrote: On Thursday, 3 March 2022 at 19:28:36 UTC, matheus wrote: I'm a simple man who uses D with the old C mentality: [...] ```d string s, str = "4A0B1de!2C9~6"; foreach(i;str){ if(i < '0' || i > '9'){ continue; } s ~= i

Re: How to use ImportC?

2022-03-03 Thread Leonardo via Digitalmars-d-learn
Thanks but not worked here. ``` [leonardo@leonardo-pc dimportc]$ dmd --version DMD64 D Compiler v2.098.1 Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved written by Walter Bright [leonardo@leonardo-pc dimportc]$ ls foo.c program.d [leonardo@leonardo-pc dimportc]$ cat

Re: How to use ImportC?

2022-03-03 Thread bachmeier via Digitalmars-d-learn
On Thursday, 3 March 2022 at 19:05:22 UTC, Leonardo wrote: I saw the new feature called ImportC, it's cool to be able to use C code/libraries, but I'm not much experience in C and didn't understand this incomplete documentation: https://dlang.org/spec/importc.html How to use ImportC? You jus

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 03, 2022 at 10:54:39PM +, matheus via Digitalmars-d-learn wrote: > On Thursday, 3 March 2022 at 21:03:40 UTC, H. S. Teoh wrote: [...] > > -- > > void main() { > > string s = "blahblah123blehbleh456bluhbluh"; > > auto result = s.filter!(ch => ch.isDigit).to!int; > > a

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread matheus via Digitalmars-d-learn
On Thursday, 3 March 2022 at 21:03:40 UTC, H. S. Teoh wrote: ... -- void main() { string s = "blahblah123blehbleh456bluhbluh"; auto result = s.filter!(ch => ch.isDigit).to!int; assert(result == 123456); } -- Problem solved. Why write 6 lines when 3 will do? Ju

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Mar 03, 2022 at 08:23:14PM +, forkit via Digitalmars-d-learn wrote: > On Thursday, 3 March 2022 at 19:28:36 UTC, matheus wrote: > > > > I'm a simple man who uses D with the old C mentality: > > > > import std.stdio; > > > > void main(){ > > string s, str = "4A0B1de!2C9~6"; > >

Re: How to use ImportC?

2022-03-03 Thread forkit via Digitalmars-d-learn
On Thursday, 3 March 2022 at 19:05:22 UTC, Leonardo wrote: I saw the new feature called ImportC, it's cool to be able to use C code/libraries, but I'm not much experience in C and didn't understand this incomplete documentation: https://dlang.org/spec/importc.html How to use ImportC? I think

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread forkit via Digitalmars-d-learn
On Thursday, 3 March 2022 at 19:28:36 UTC, matheus wrote: I'm a simple man who uses D with the old C mentality: import std.stdio; void main(){ string s, str = "4A0B1de!2C9~6"; foreach(i;str){ if(i < '0' || i > '9'){ continue; } s ~= i; } writeln("Result: ", s);

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread matheus via Digitalmars-d-learn
On Thursday, 3 March 2022 at 12:14:13 UTC, BoQsc wrote: I've looked around and it seems using regex is the only closest solution. I'm a simple man who uses D with the old C mentality: import std.stdio; void main(){ string s, str = "4A0B1de!2C9~6"; foreach(i;str){ if(i < '0' ||

How to use ImportC?

2022-03-03 Thread Leonardo via Digitalmars-d-learn
I saw the new feature called ImportC, it's cool to be able to use C code/libraries, but I'm not much experience in C and didn't understand this incomplete documentation: https://dlang.org/spec/importc.html How to use ImportC?

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread bachmeier via Digitalmars-d-learn
On Thursday, 3 March 2022 at 13:55:47 UTC, BoQsc wrote: On Thursday, 3 March 2022 at 13:25:32 UTC, Stanislav Blinov wrote: On Thursday, 3 March 2022 at 12:14:13 UTC, BoQsc wrote: I need to check if a string contains integers, and if it contains integers, remove all the regular string characte

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 3 March 2022 at 13:25:32 UTC, Stanislav Blinov wrote: auto filtered = () { auto r = args[1].find!isNumber; // check if a string contains integers ``` **When using ```find!isNumber```:** ``` 0123456789 @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ `abcdefghijklmnop

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread BoQsc via Digitalmars-d-learn
On Thursday, 3 March 2022 at 13:25:32 UTC, Stanislav Blinov wrote: On Thursday, 3 March 2022 at 12:14:13 UTC, BoQsc wrote: I need to check if a string contains integers, and if it contains integers, remove all the regular string characters. I've looked around and it seems using regex is the on

Re: How to remove all characters from a string, except the integers?

2022-03-03 Thread Stanislav Blinov via Digitalmars-d-learn
On Thursday, 3 March 2022 at 12:14:13 UTC, BoQsc wrote: I need to check if a string contains integers, and if it contains integers, remove all the regular string characters. I've looked around and it seems using regex is the only closest solution. ```d import std.stdio; import std.algorithm

How to remove all characters from a string, except the integers?

2022-03-03 Thread BoQsc via Digitalmars-d-learn
I need to check if a string contains integers, and if it contains integers, remove all the regular string characters. I've looked around and it seems using regex is the only closest solution. ``` import std.stdio; void main(string[] args){ if (args.length > 1){

Re: Colors in Raylib

2022-03-03 Thread meta via Digitalmars-d-learn
On Tuesday, 1 March 2022 at 15:37:55 UTC, Ali Çehreli wrote: On 3/1/22 07:19, Mike Parker wrote: > On Tuesday, 1 March 2022 at 13:15:09 UTC, meta wrote: > >> >> enum Color >> { GRAY } >> >> void setColor(Color color); >> >> setColor(GRAY); > > Then that defeats the purpose of havi