Grep not working - special characters??

I have a file that I am processing with a while loop from, in come cases the grep/sed command (strings record | grep �errorDetail� | sed 's&*errorDetail\(.*)\(/errorDetail\).&\1&') works and produces the data I am after and in some it does not. I have inspected the data within the failing records, they definitely contain the 'errorDetail' field that I am after. I am of a strong suspicion that some of the records contain some characters that the grep does not like. However, I do not know which chars. It may be some binary character that is causing the problem. When I put each record thorugh s/[!@#\$%^&()]//g' filename, some of the records that were giving me incorrect data give me the errorDetail. However, not all. Any ideas how I can resolve this issue?

To exclude those characters you can do something like:

sed 's/[^a-zA-Z0-9]//g' file

Place the characters you want to print within the brackets.

Regards

The sed command has helped in extracting the data I want, however, I lose some of formating i.e. spaces in words. It appears that is what is causing the problem. If I convert the data using sed s'/[^a-zA-Z0-9]//g' it gets the data I want. If I convert using s'/[^a-zA-Z0-9<>:]//g' it too gets the data I want. However when I convert the data using s'/[^a-zA-Z0-9<>: ]//g' that's when I hit the problem. So is there a way of subsituting the space with some character, extarct the data I am intrested in and then converting the character back to space?

It should works with spaces, also try to exclude the TAB within the brackets. To get a TAB, first press <Ctr>-V and then the TAB key.
If you want to convert the space first to another character be sure that this character should not be in your file.
An example to convert the space to an underscore and back to a space:

 sed -e 's/ /_/g' file -e 's/[^a-zA-Z0-9_]//g' -e 's/_/ /g'