Pattern Match on String Column

Greg Berns
New Contributor

Pattern Match on String Column

In many functional programming languages there is a way to do pattern matching, like F# has `match expression with`.


In my use case, I'd like to match a string to a set of strings/regexes and returning a value(a string):



// path:string
iif(path == '/', 'home',
iif(path == '/search', 'search',
iif(path == '/*/*/*-for-sale-*', 'product',



The `iif` syntax is really ugly though. Is there a more concise way to find a string match and return a value?

1 Reply

Re: Pattern Match on String Column



One of the string operators is matches that allow you to perform regular expression matches.

There are also other methods to check regular expressions.




Related Conversations