Jump to content

[SOLVED] preg_replace how to allow ^a-z0-9-,._


sayedsohail

Recommended Posts

Hi everyone,

This is my preg_replace which works fine and replaces all characters other than the set specified within ^a-z0-9, but how do i change this to allow ^a-z0-9 plus (-,._), and single space between the $var value

 

i.e,

 

cat's      ltd., UK

to

cat's ltd., UK

 

$var1 = preg_replace('/([^a-z0-9 ])/i', '', $var);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.