You can delete all line sections that are inside a continuous border line or which intersect with the border line. The border line is a closed polyline.
Concatenating Lines