# Problem with split.(...)

This is Julia 0.6.2.

julia> P = [“{FRBRTXBLBB3|Gig8”, “0/0/16|TenGig/0/0/16,10G}”, “7/0/1|TenGig/7/0/1,10G,340}”];

julia> strip.(P, [‘{’,‘}’])
ERROR: DimensionMismatch(“arrays could not be broadcast to a common size”)
Stacktrace:
[1] _bcs1(::Base.OneTo{Int64}, ::Base.OneTo{Int64}) at ./broadcast.jl:70
[2] _bcs at ./broadcast.jl:63 [inlined]
[3] broadcast_shape at ./broadcast.jl:57 [inlined] (repeats 2 times)

julia>

Am I doing something wrong here?

This is actually exactly the same problem as Vectorization and passing a matrix as an argument - #2 by rdeits from earlier today. If you want each element in `P` to receive the entire vector `['{', '}']`, then you can wrap that vector in a one-element tuple (to “scalarize” it):

``````julia> P = ["{foo", "bar}", "baz}"]
3-element Array{String,1}:
"{foo"
"bar}"
"baz}"

julia> strip.(P, ['{', '}'])
ERROR: DimensionMismatch("arrays could not be broadcast to a common size")
Stacktrace:
[1] _bcs1(::Base.OneTo{Int64}, ::Base.OneTo{Int64}) at ./broadcast.jl:70
[2] _bcs at ./broadcast.jl:63 [inlined]
[3] broadcast_shape at ./broadcast.jl:57 [inlined] (repeats 2 times)

julia> strip.(P, (['{', '}'],))
3-element Array{String,1}:
"foo"
"bar"
"baz"
``````

Also, please quote your code: PSA: how to quote code with backticks

1 Like

Ah, thanks. A one-element tuple sounds tricky, however.
I ended up solving the problem by using `map(x -> strip(x,['{','}']), P)`.