From: Blair Z. <bl...@or...> - 2004-04-26 19:52:31
|
Nicolas Cannasse wrote: > > > > I added the following to ExtString : > > > > > > val strip : ?chars:string -> string -> string > > > val nsplit : string -> string -> string list > > > val join : string -> string list -> string ( = concat ) > > > > > > I'm not sure about lstrip, rstrip and rchop_if > > > > lstrip and rstrip are useful in some cases. For instance, if you wish > > to remove trailing whitespace such as \n but preserve leading whitespace > > (perhaps it's indentation that you wish to keep), rstrip is useful. > > what about : strip ~chars:"\n" then ? Maybe to be consistent with Perl's function, name it chomp? chomp This safer version of "chop" removes any trailing string that corresponds to the current value of $/ (also known as $INPUT_RECORD_SEPARATOR in the "English" module). It returns the total number of characters removed from all its arguments. It's often used to remove the newline from the end of an input record when you're worried that the final record may be missing its newline. When in paragraph mode ("$/ = """), it removes Best, Blair -- Blair Zajac <bl...@or...> Plots of your system's performance - http://www.orcaware.com/orca/ |