Translate PHP function to jQuery
I currently fetch a GET-param via PHP and run through at PHP funtion. Now I need that value for a jQuery script on the site. So how can I do the following in jQuery?

    function trimQuery($query){
    	
    	$query = trim($query);
    	
    	$query = preg_replace("/[^a-zåäö0-9\s]/i","",$query);
    
    	return $query;
    
    }
    
    $trimmedQuery = trimQuery($_GET['q']);
    
    $arrayTrimmedQuery = explode(" ",trimmedQuery );
    
    foreach(arrayTrimmedQuery as $value){
    
      echo $value;
    
    }
Translate PHP function to jQuery
===

I currently fetch a GET-param via PHP and run through at PHP funtion. Now I need that value for a jQuery script on the site. So how can I do the following in jQuery?

    function trimQuery($query){
    	
    	$query = trim($query);
    	
    	$query = preg_replace("/[^a-zåäö0-9\s]/i","",$query);
    
    	return $query;
    
    }
    
    $trimmedQuery = trimQuery($_GET['q']);
    
    $arrayTrimmedQuery = explode(" ",trimmedQuery );
    
    foreach(arrayTrimmedQuery as $value){
    
      echo $value;
    
    }