Thread overview | |||||
---|---|---|---|---|---|
|
December 10, 2011 strip and dmd 2.056 | ||||
---|---|---|---|---|
| ||||
dear, it seem now we can not use this: ";;;;;;blah".stripLeft(";"); Error: template std.string.stripl(String) cannot deduce template function from argument types !()(string,string) they are another way ? |
December 10, 2011 Re: strip and dmd 2.056 | ||||
---|---|---|---|---|
| ||||
Posted in reply to bioinfornatics | bioinfornatics: > it seem now we can not use this: > ";;;;;;blah".stripLeft(";"); > Error: template std.string.stripl(String) cannot deduce template > function from argument types !()(string,string) > > > they are another way ? In Python str.lstrip accepts an optional argument: >>> ";;;;;;blah".lstrip(";") 'blah' But I think with the current Phobos you need to use something like this: import std.stdio, std.string; void main() { string s = ";;;;;;blah"; munch(s, ";"); writeln(s); } Bye, bearophile |
December 10, 2011 Re: strip and dmd 2.056 | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Saturday, December 10, 2011 16:18:22 bearophile wrote:
> bioinfornatics:
> > it seem now we can not use this:
> > ";;;;;;blah".stripLeft(";");
> > Error: template std.string.stripl(String) cannot deduce template
> >
> > function from argument types !()(string,string)
> >
> >
> > they are another way ?
>
> In Python str.lstrip accepts an optional argument:
> >>> ";;;;;;blah".lstrip(";")
>
> 'blah'
>
>
> But I think with the current Phobos you need to use something like this:
>
> import std.stdio, std.string;
> void main() {
> string s = ";;;;;;blah";
> munch(s, ";");
> writeln(s);
> }
None of the strip or split functions in Phobos deal with anything other than whitespace. splitter is more general, but there is no stripper (which would arguably be a horrible name for a function anyway). However, that's essentially what find does, albeit with the predicate effectively being reversed. e.g.
find!"a != ';'"(";;;;;blah");
- Jonathan M Davis
|
Copyright © 1999-2021 by the D Language Foundation