Search code examples
postgresqlnon-english

How to remove Non-English characters in Postgresql


I have been trying to remove rows that have non-english words in Postgresql. However, it does not seem working. This is my current code and sample data:

Select
translationid,
medium
from translation
where medium like '%[^A-Z,a-z]%'

enter image description here


Solution

  • You need a regular expression match with the ~ operator:

    WHERE NOT meduim ~ '[^A-Za-z]'
    

    You might want to add other characters like space or - to the list in the brackets.