that's a pretty simple regex
all you have to do is filter all characters NOT in the set of A through Z, a through z, and space
the regex for that is /[A-Za-z ]/
everything in the brackets is a set of single characters. the ^ means NOT one of the following characters .. and the hyphen just means to use an ASCII range from the char before to the char after the hyphen
some example code (depending on your ver of php you may have to change the PHP_SELF and GET vars ..)
<html>
<head>
</head>
<body>
<form action='<?=$GLOBALS['PHP_SELF']?>' method='get'>
<input name='query' type='text' value='<?=htmlentities($_GET['query'],ENT_QUOTES)?>'>
<input type='submit' value='search'>
</form>
<?php
if (@$_GET['query'])
{
$query = preg_replace("/[^A-Za-z ]/","",$_GET['query']);
}
?>
original query was - <b><?=$_GET['query']?></b>
<br>
filtered query is - <b><?=$query?></b>
</body>
</html>
simpler regular expressions aren't that hard. the rules are all simple, it's just putting lots of them together that makes them so ugly and intimidating
do a google search for 'regular expression tutorial' to learn more