Jump to content

remove non-alphanumeric characters except underscore


Nodral

Recommended Posts

Hi

 

I need to strip all non alphanumeric characters from a string except an underscore.

 

Here's what I have so far which works from the non alphanumeric bit, how do I then ignore underscores?

 

$value = ereg_replace("[^A-Za-z0-9]", "", $value );

 

Any help would be greatly appreciated.

Ok, done that and it removes all characters.  I think i'm getting a certain amount of 'garbage' in my strings, due to them being imported from a tab seperated csv file.  Any thoughts how I can 'clean' the input, or check it is set to the correct encoding?

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.