Closed skx closed 2 years ago
I looked at using evalfilter to embed some scripting in my utility-project, but one omission killed that:
evalfilter
Specifically I wanted to turn "foo bar baz.pdf" into "foo_bar_baz.pdf" (i.e. change spaces to underscores).
You could turn a string into an array with split, but you're missing the join to turn the array back into a string:
split
name = join( split( name, " " ), "_" )
Adding join is a no-brainer, to allow this problem to be solved indirectly. Of course we should also support replace to allow:
join
replace
name = replace( name, / /, "_" )
That would do regular expression replacement. I'm not sure if that is better than a character replacement, but i suspect it is..
However both failed the linter as my attempt to compare whether a floating-point number was secretly an integer failed. This is an update from golangci-lint and will be resolved shortly.
golangci-lint
I looked at using
evalfilter
to embed some scripting in my utility-project, but one omission killed that:Specifically I wanted to turn "foo bar baz.pdf" into "foo_bar_baz.pdf" (i.e. change spaces to underscores).
You could turn a string into an array with
split
, but you're missing the join to turn the array back into a string:Adding
join
is a no-brainer, to allow this problem to be solved indirectly. Of course we should also supportreplace
to allow:That would do regular expression replacement. I'm not sure if that is better than a character replacement, but i suspect it is..