www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - strip and dmd 2.056

reply bioinfornatics <bioinfornatics fedoraproject.rog> writes:
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 ?
Dec 10 2011
next sibling parent bearophile <bearophileHUGS lycos.com> writes:
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(";")



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
Dec 10 2011
prev sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
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
Dec 10 2011