Skip to content

Instantly share code, notes, and snippets.

@thiagomata
Last active June 28, 2016 03:47
Show Gist options
  • Save thiagomata/bd2d06e195a4b9bbec1078cb7770da8b to your computer and use it in GitHub Desktop.
Save thiagomata/bd2d06e195a4b9bbec1078cb7770da8b to your computer and use it in GitHub Desktop.
Replace Accents Characters to Ascii in Regex Variable using Sed.
echo '{"doNotReplaceKey":"bábögêjírù","replaceValueKey":"bábögêjírù"}' \
| sed -e ':a;s/replaceValueKey":"\(.*\)[áâàãä]/replaceValueKey":"\1a/g;ta' \
| sed -e ':a;s/replaceValueKey":"\(.*\)[éêèë]/replaceValueKey":"\1e/g;ta' \
| sed -e ':a;s/replaceValueKey":"\(.*\)[íîìï]/replaceValueKey":"\1i/g;ta' \
| sed -e ':a;s/replaceValueKey":"\(.*\)[óôòõö]/replaceValueKey":"\1o/g;ta' \
| sed -e ':a;s/replaceValueKey":"\(.*\)[úûùü]/replaceValueKey":"\1u/g;ta'
# result:
# {"doNotReplaceKey":"bábögêjírù","replaceValueKey":"babogejiru"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment