6

On the Couchbase documentation

https://docs.couchbase.com/server/6.0/n1ql/n1ql-language-reference/patternmatchingfun.html

I saw that:

REGEXP_CONTAINS(expression, pattern)
Returns True if the string value contains the regular expression pattern.

REGEXP_LIKE(expression, pattern)
Returns True if the string value contains the regular expression pattern.

Is there any difference between this functions or one is an alias for another?

Andrei Lupuleasa
  • 2,677
  • 3
  • 14
  • 32

1 Answers1

8

REGEXP_LIKE() requires that the expression exactly match the pattern. REGEXP_CONTAINS() is less restrictive; the expression only has to contain something that matches the pattern.

This query illustrates the difference. Note that the pattern being searched for is the second parameter to the function.

select REGEXP_CONTAINS("  foof  ", "foof") as contains, REGEXP_LIKE("  foof  ", "foof") as `like`

[
  {
    "contains": true,
    "like": false
  }
]
Johan Larson
  • 1,880
  • 1
  • 11
  • 14