用php验证/更改输入值

i want to validate and change the input value from a wordpress search form.

<?php $unique_id = esc_attr( uniqid( 'search-form-' ) ); ?>

<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
    <label for="<?php echo $unique_id; ?>">
        <span class="screen-reader-text"><?php echo _x( 'Search for:', 'label', 'twentyseventeen' ); ?></span>
    </label>


    <input type="search" id="<?php echo $unique_id; ?>" class="search-field" placeholder="<?php echo esc_attr_x( 'Search &hellip;', 'placeholder', 'twentyseventeen' ); ?>" value="<?php echo get_search_query(); ?>" name="s" />


    <button type="submit" class="search-submit">
<?php echo twentyseventeen_get_svg( array( 'icon' => 'search' ) ); ?><span class="screen-reader-text"><?php echo _x( 'Search', 'submit button', 'twentyseventeen' ); ?></span></button>
</form>

I used this code to change value but it aint working ;-(

this should remove all characters with and after TEST but it aint.

Am i missing something?

At the end i want to validate the input value and when it contains specific words it needs to be changed into clean search strings.

What excactly you have tried? It looks like the normal searchform of Wordpress.

To modify the query you have to hook into pre_get_posts function:

function your_filter($query) {
    if (!$query->is_search) {
        return $query;
    }

    // your code here

    return $query;
}
//hook
add_filter('pre_get_posts','your_filter');

For escaping the search value you can do something like this:

value="<?php echo doWhatEverYouWantFunction(get_search_query()); ?>"