<?php
// Add custom Theme Functions here
add_filter( 'wp_insert_post_data' , 'filter_post_data' , '99', 2 );

function filter_post_data( $data , $postarr ) {
    // Change post content
    $post_content = $data['post_content'];
    $data['post_content'] = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $post_content);
    return $data;
}