Nov 08
Jolle Carlestam removeleading with limits
Nov 08, 2015; 10:54
Jolle Carlestam
removeleading with limits
I was in the need of removing leading chars but the plain string -> removeleading was too ambitious.
For example if you apply
’00001’ -> removeleading(’0’) it will leave ’1’. You can’t use the method if you only want to remove say one ’0’.
So I added a signature to fix this:
define string -> removeleading(find::string, count::integer)=> {
local(looped = 0)
{
#looped++
!.beginsWith(#find)?
return
.remove(1, #find->size)
#looped < #count ?
currentCapture->restart
}()
}
This allows you to do
’00001’ -> removeleading(’0’, 1)
’00001’ -> removeleading(’0’, 2)
’00001’ -> removeleading(’0’, 3)
->
0001
001
01
The plain, standard, string -> removeleading of course continues to work as before.
HDB
Jolle
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso Lasso@lists.lassosoft.com
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>
Nov 08
Johan Solve Re: removeleading with limits
Nov 08, 2015; 17:54
Johan Solve
Re: removeleading with limits
Nov 08
Jolle Carlestam Re: removeleading with limits
Nov 08, 2015; 18:02
Jolle Carlestam
Re: removeleading with limits
Nov 10
Bil Corry Re: removeleading with limits
Nov 10, 2015; 14:17
Bil Corry
Re: removeleading with limits
Nov 10
Jolle Carlestam Re: removeleading with limits
Nov 10, 2015; 15:01
Jolle Carlestam
Re: removeleading with limits