# The `=~` operator

## Returns correct result when used on two `String`s

### Juttle

    emit -from Date.new(0) -limit 1
      | put ma = 'abcd' =~ 'abcd'
      | put nm = 'abcd' =~ 'efgh'
      | view result

### Output

    { "time": "1970-01-01T00:00:00.000Z", ma: true, nm: false }

## Returns correct result when used on a non-`String` and a `String`

### Juttle

    emit -from Date.new(0) -limit 1
      | put nm = null =~ 'abcd'
      | view result

### Output

    { "time": "1970-01-01T00:00:00.000Z", nm: false }

## Returns correct result when used on a `String` and a `RegExp`

### Juttle

    emit -from Date.new(0) -limit 1
      | put ma = 'abcd' =~ /abcd/
      | put nm = 'abcd' =~ /efgh/
      | view result

### Output

    { "time": "1970-01-01T00:00:00.000Z", ma: true, nm: false }

## Returns correct result when used on a non-`String` and a `RegExp`

### Juttle

    emit -from Date.new(0) -limit 1
      | put nm = null =~ /abcd/
      | view result

### Output

    { "time": "1970-01-01T00:00:00.000Z", nm: false }

## Produces an error when used on invalid operand type combinations

### Juttle

    emit -from Date.new(0) -limit 1
      | put result = null =~ null
      | view result

### Errors

  * Invalid operand types for "=~": null and null.

## '*' matches correctly

### Juttle

    emit -points [{ "str":"*" }, { "str":"x" }, { "str": "" }]
      | filter str ~ "*"
      | view result

### Output

    { str: "*" }
    { str: "x" }
    { str: "" }

## '\\\\\*' matches literal '*' only

### Juttle

    emit -points [{ "str":"*" }, { "str":"x" }, { "str": "" }]
      | filter str ~ "\\*"
      | view result

### Output

    { str: "*" }

## '?' matches correctly

### Juttle

    emit -points [{ "str":"?" }, { "str":"x" }, { "str": "" }]
      | filter str ~ "?"
      | view result

### Output

    { str: "?" }
    { str: "x" }

## '\\\\?' matches literal '?' only

### Juttle

    emit -points [{ "str":"?" }, { "str":"x" }, { "str": "" }]
      | filter str ~ "\\?"
      | view result

### Output

    { str: "?" }
