Efficient string-matching allowing for non-overlapping inversions