Cutting the Ends of an Array
Boolean does the trick if you use the right object. You can also use an array modifier for the cutting object to have the same pattern without adjusting manually.
(In my example I switched to carve solver)