digitalmars.D.learn - sub() in D2?
- adamss3 (3/3) Jan 30 2012 Is there a direct analog to sub() in D2? The replace() function in rege...
- Adam D. Ruppe (5/5) Jan 30 2012 http://www.d-programming-language.org/phobos/std_array.html#replace
- adamss3 (1/1) Jan 30 2012 Thanks.
- Marco Leise (3/4) Jan 30 2012 The only downside of strings being arrays: a lot of typical string
- Jacob Carlborg (5/9) Jan 30 2012 If everything in std.array works for strings as well, shouldn't
- Jonathan M Davis (17/26) Jan 30 2012 You could quickly get into similar arguments with std.range and std.algo...
Is there a direct analog to sub() in D2? The replace() function in regex seems a bit overkill for what I need. I just want to substitute one string for another.
Jan 30 2012
http://www.d-programming-language.org/phobos/std_array.html#replace import std.array; string a = "test"; string b = a.replace("t, "p"); assert(b == "pesp");
Jan 30 2012
Am 30.01.2012, 16:57 Uhr, schrieb adamss3 <sadams58 woh.rr.com>:Thanks.The only downside of strings being arrays: a lot of typical string functions are in std.array. :D
Jan 30 2012
On 2012-01-31 00:09, Marco Leise wrote:Am 30.01.2012, 16:57 Uhr, schrieb adamss3 <sadams58 woh.rr.com>:If everything in std.array works for strings as well, shouldn't std.string publicly import std.array? -- /Jacob CarlborgThanks.The only downside of strings being arrays: a lot of typical string functions are in std.array. :D
Jan 30 2012
On Tuesday, January 31, 2012 08:16:25 Jacob Carlborg wrote:On 2012-01-31 00:09, Marco Leise wrote:You could quickly get into similar arguments with std.range and std.algorithm, as well as std.ascii and std.uni. Ultimately, functions are organized into modules based on where they make the most sense to ones writing the functions, and you import the modules that have what you need. You can't get away from having to know what module has what you need unless we get something like std.all which publicly imports _everything_. And the folks who get paranoid about importing symbols that they don't need are going to tend to want modules to include _less_ rather than more. So, there's that to contend with as well. No matter how you organize the functions, there will always been problems with it. Ultimately, you just learn where what you need is. And in this case, a string is an array, so as long as you understand that, std.array should definitely be one of the places that you look for functions when messing with strings, not just std.string. - Jonathan M DavisAm 30.01.2012, 16:57 Uhr, schrieb adamss3 <sadams58 woh.rr.com>:If everything in std.array works for strings as well, shouldn't std.string publicly import std.array?Thanks.The only downside of strings being arrays: a lot of typical string functions are in std.array. :D
Jan 30 2012