Pattern Match on String Column

Highlighted
Deleted
Not applicable

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',
'other',
)))

```

 

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

1 Reply
Highlighted

Hi,

 

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

There are also other methods to check regular expressions.

 

Thanks,

Meir