Search code examples
sqlregexsnowflake-cloud-data-platform

Regex to Exclude records which does not have any vowels on Snowflake not working


I am trying for a regex function to exclude the records which does not have a vowel in it. Similar way to remove records which does not have consonant in it. It looks like the regular regex is not working as expected in snowflake.

select REGEXP_LIKE(name, '[aeiouy]', 'i') 


Solution

  • You were close. Snowflake's regexp_like assumes start and end anchors, so your expression translates to

    regexp_like(name, '^[aeiouy]$', 'i');
    

    You want to modify that to

    regexp_like(name, '.*[aeiouy].*', 'i');