Trying to remove plural ‘s’ from search Query but it’s just removing every letter of the end – what am I doing wrong? Thanks

Try this:

function mySearchFilterFunction($query) {
  if ( !is_admin() && $query->is_main_query() && $query->is_search) {
    $search_term = $query->get('s');
    if (substr($search_term, -1) == 's'){
      $search_term = substr($search_term, 0, -1);
    }
    $query->set('s', $search_term);
  }
}
add_action( 'pre_get_posts', 'mySearchFilterFunction');