Viewed   247 times

How can I use preg_match to see if special characters [^'£$%^&*()}{@:'#~?><>,;@|-=-_+-¬`] exist in a string?



[W]+ will match any non-word character.

but to match only the characters from the question, use this:

  if(preg_match("/[[^'£$%^&*()}{@:'#~?><>,;@|\-=-_+-¬`]]/", $string)){
   //this string contain atleast one of these [^'£$%^&*()}{@:'#~?><>,;@|-=-_+-¬`] characters
Friday, September 2, 2022

Here's what worked best for me when trying to script this (in case anyone else comes across this like I did):

$ pecl -d php_suffix=5.6 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.0 install <package>
$ pecl uninstall -r <package>

$ pecl -d php_suffix=7.1 install <package>
$ pecl uninstall -r <package>

The -d php_suffix=<version> piece allows you to set config values at run time vs pre-setting them with pecl config-set. The uninstall -r bit does not actually uninstall it (from the docs):

vagrant@homestead:~$ pecl help uninstall
pecl uninstall [options] [channel/]<package> ...
Uninstalls one or more PEAR packages.  More than one package may be
specified at once.  Prefix with channel name to uninstall from a
channel not in your default channel (

  -r, --register-only
        do not remove files, only register the packages as not installed

The uninstall line is necessary otherwise installing it will remove any previously installed version, even if it was for a different PHP version (ex: Installing an extension for PHP 7.0 would remove the 5.6 version if the package was still registered as installed).

Monday, December 12, 2022
$ts = array("/[À-Å]/","/Æ/","/Ç/","/[È-Ë]/","/[Ì-Ï]/","/Ð/","/Ñ/","/[Ò-ÖØ]/","/×/","/[Ù-Ü]/","/[Ý-ß]/","/[à-å]/","/æ/","/ç/","/[è-ë]/","/[ì-ï]/","/ð/","/ñ/","/[ò-öø]/","/÷/","/[ù-ü]/","/[ý-ÿ]/");
$tn = array("A","AE","C","E","I","D","N","O","X","U","Y","a","ae","c","e","i","d","n","o","x","u","y");
preg_replace($ts,$tn, $p);

Make an array of the special characters and an array of the regular character and use preg_replace() on the string like above.

Thursday, December 22, 2022

Never used any of those, but they look interesting..

Take a look at Gearman as well.. more overhead in systems like these but you get other cool stuff :) Guess it depends on your needs ..

Friday, November 11, 2022

I think the best way would be to create a keyboard layout from scratch, using the Microsoft Keyboard Layout Creator.

You can load an existing layout and customize it however you want, or create a brand new one, including combinations with modifier keys.

Sunday, October 30, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :