A particular case of strip.
is not working.
julia> a = " abc , (de f) , gh "
" abc , (de f) , gh "
julia> b = split(a, ',')
3-element Array{SubString{String},1}:
" abc "
" (de f) "
" gh "
julia> strip.(b, [' ', '(', ')']) # the strip affect only the first element of b
3-element Array{SubString{String},1}:
"abc"
" (de f) "
" gh "
julia> strip.(b, [' ']) # with only one seperator it'll affect all elements
3-element Array{SubString{String},1}:
"abc"
"(de f)"
"gh"
julia> strip.(b[2], [' ', '(', ')']) # I don't get what happened here, i pressed Enter by mistake
3-element Array{SubString{String},1}:
"(de f)"
" (de f) "
" (de f) "
julia> strip(b[2], [' ', '(', ')']) # strip works with multiple separators
"de f"
That my be me but I tried at first with "
and got an error:
julia> strip.(split(a, [',']), [' ', '"'])
ERROR: DimensionMismatch("arrays could not be broadcast to a common size")
Stacktrace:
[1] _bcs1 at ./broadcast.jl:438 [inlined]
[2] _bcs at ./broadcast.jl:432 [inlined]
[3] broadcast_shape at ./broadcast.jl:426 [inlined]
[4] combine_axes at ./broadcast.jl:421 [inlined]
[5] instantiate at ./broadcast.jl:255 [inlined]
[6] materialize(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(strip),Tuple{Array{SubString{String},1},Array{Char,1}}}) at ./broadcast.jl:753
[7] top-level scope at none:0
julia> strip.(split(a, [',']), [' ', '\"'])
ERROR: DimensionMismatch("arrays could not be broadcast to a common size")
Stacktrace:
[1] _bcs1 at ./broadcast.jl:438 [inlined]
[2] _bcs at ./broadcast.jl:432 [inlined]
[3] broadcast_shape at ./broadcast.jl:426 [inlined]
[4] combine_axes at ./broadcast.jl:421 [inlined]
[5] instantiate at ./broadcast.jl:255 [inlined]
[6] materialize(::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1},Nothing,typeof(strip),Tuple{Array{SubString{String},1},Array{Char,1}}}) at ./broadcast.jl:753
[7] top-level scope at none:0
@kristoffer.carlsson redirect me here, thanks, with this solution.
julia> strip.(b, ([' ', '(', ')'],))
3-element Array{SubString{String},1}:
"abc"
"de f"
"gh"
Still Iām not comfortable with this definition of strip.
. What can justify that the optional chars
argument should be a Tuple of Array (Tuple of Tuple or Array of Array works too) for strip.
?
Maybe I havenāt yet understood the dot effect on functions because in my mind strip.(b, [' ', '(', ')'])
should give the same result as strip.(b, ([' ', '(', ')'],))