FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date.

For more details, review the migration guide. Contact support@fauna.com with any questions.

RegexEscape

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

RegexEscape( value )
regex_escape( value )
RegexEscape( value )
RegexEscape( value )
RegexEscape( value )

Description

The RegexEscape function returns an escaped regular expression that matches the value string verbatim. The returned regular expression is simply the value string surrounded by the \Q and \E escape sequences.

Parameters

Parameter Type Definition and Requirements

value

String

The String to convert to an escaped regular expression.

Returns

Returns a regular expression String.

Examples

The following query converts a string into an escaped regular expression:

client.query(
  q.RegexEscape('.Fa*[un]a{1,}')
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
\Q.Fa*[un]a{1,}\E
result = client.query(
  q.regex_escape(".Fa*[un]a{1,}")
)
print(result)
\Q.Fa*[un]a{1,}\E
result, err := client.Query(
	f.RegexEscape(".Fa*[un]a{1,}"))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
\Q.Fa*[un]a{1,}\E
try
{
    Value result = await client.Query(
        RegexEscape(".Fa*[un]a{1,}")
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
StringV(\Q.Fa*[un]a{1,}\E)
RegexEscape('.Fa*[un]a{1,}')
'\\Q.Fa*[un]a{1,}\\E'
Query metrics:
  •    bytesIn:  31

  •   bytesOut:  34

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 2ms

  •    retries:   0

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!