Regular Expression only allow alphanumeric plus other specific characters

With a PHP function I'm trying to create a RegEx string for preg_replace that will only allow alphanumeric characters plus ! @ # $ % & . ,

The PHP function is

 function clean($var) {
    $regEx="REGEXSTRING";   
    $var = preg_replace($regEx, "", $var);
    return str_replace(array("&", "'"),
    array("&", "'"), $var);
}

What would the string be to match what I'm looking for.

:: EDIT :: As I was typing this I figured out what would work for me. Not sure if it is the best solution but it works. But I figured I'd post it here as a solution for other beginners.

The string I used is...

$regEx="/[^a-zA-Z0-9 !@#$%&.,]/";

Hope it helps someone.

Answers


 function clean($var) {
    $regEx="/[^a-zA-Z0-9 !@#$%&.,]/"; 
    $var = preg_replace($regEx, "", $var);
    return str_replace(array("&", "'"),
    array("&", "'"), $var);
}

Need Your Help

Passing parameters to msi without msiexec.

wix windows-installer bootstrapper

I'm trying pass some parameters to an MSI from bootstrapper. Because I need MSI be able to display UI, but in basic varitant (/qb). At the moment I'm doing it the following way:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.