ContainsStrRegex

ContainsStrRegex( value, pattern )
ContainsStrRegex( value, pattern )
ContainsStrRegex( value, pattern )
ContainsStrRegex( value, pattern )
contains_str_regex( value, pattern )
ContainsStrRegex( value, pattern )

Description

The ContainsStrRegex function returns true when the value string matches the pattern regular expression, or false when it does not.

Parameters

Argument Type Definition and Requirements

value

The string to compare.

pattern

The regular expression to match within value.

Returns

Returns a boolean: true when value matches the pattern regular expression, or false when it does not.

Examples

The following query demonstrates the case where the value string matches the pattern regular expression:

Value result = await client.Query(
  ContainsStrRegex("Fauna", "(Fa|na)")
);

IResult<Value> data = result.To<Value>();
data.Match(
  Success: value => Console.WriteLine($"{value}"),
  Failure: error => Console.WriteLine($"Query failed:\n{error}")
);
BooleanV(True)
  result, err := client.Query(
    f.ContainsStrRegex("Fauna", "(Fa|na)"))

  if (err != nil) {
    fmt.Println(err)
  } else {
    fmt.Println(result)
  }
true
System.out.println(
    client.query(
        ContainsStrRegex("Fauna", "(Fa|na)")
    ).get()
);
true
client.query(
  q.ContainsStrRegex('Fauna', '(Fa|na)')
)
.then((ret) => console.log(ret))
true
print(client.query(
  q.contains_str_regex("Fauna", "(Fa|na)")
))
True
println(Await.result(
  client.query(
    ContainsStrRegex("Fauna", "(Fa|na)"),
  ),
  5.seconds
))
true

The following query demonstrates the case where the value string does not match the pattern regular expression:

Value result = await client.Query(
  ContainsStrRegex("Fauna", ".Faa*")
);

IResult<Value> data = result.To<Value>();
data.Match(
  Success: value => Console.WriteLine($"{value}"),
  Failure: error => Console.WriteLine($"Query failed:\n{error}")
);
BooleanV(False)
result, err := client.Query(
  f.ContainsStrRegex("Fauna", ".Faa*"))

if (err != nil) {
  fmt.Println(err)
} else {
  fmt.Println(result)
}
false
System.out.println(
    client.query(
        ContainsStrRegex("Fauna", ".Faa*")
    ).get()
);
false
client.query(
  q.ContainsStrRegex('Fauna', '.Faa*')
)
.then((ret) => console.log(ret))
false
print(client.query(
  q.contains_str_regex("Fauna", ".Faa*")
))
False
println(Await.result(
  client.query(
    ContainsStrRegex("Fauna", ".Faa*"),
  ),
  5.seconds
))
false

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!