1

I would like to remove all special characters contained in a string. I tried some sample script but it doesn't remove all special characters.

echo "SamPlE_@tExT%, reééééally ?" | sed -e 's/[^a-z^A-Z]//g'

Output : tExTreééééaôlly

Expected : tExTreally

executable
  • 3,365
  • 6
  • 24
  • 52

1 Answers1

2

The simplest would be to run the command with the C locale:

echo "SamPlE_@tExT%, reééééally ?" | LANG=C sed 's/[^a-zA-Z]//g'

Output:

SamPlEtExTreally
hek2mgl
  • 152,036
  • 28
  • 249
  • 266