Skip to main content

Regex.escape

Regex.escapeexpression

Documentation

Escape the special characters in expression such that the result is a valid literal pattern for the original string.

Arguments

  • expression: The expression to escape metacharacters in.

Examples

Turn a Text into a regex that matches that string exactly.

      example_escape =
literal_string = "\!\.|abcde"
Regex.escape literal_string