Bug #100698 Awfully vague statement regarding doubling slashes in REGEXP arguments
Submitted: 31 Aug 2020 15:03 Modified: 11 Feb 2021 15:02
Reporter: teo teo Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S2 (Serious)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[31 Aug 2020 15:03] teo teo
Description:
https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp

This statement is outrageously vague:

"Note
Because MySQL uses the C escape syntax in strings (for example, \n to represent the newline character), you must double any \ that you use in your expr and pat arguments.
"

Taken as-is, it's outright false. For example:

  SELECT * FROM sometable WHERE somefield REGEXP 'foo\n'

That is, if you want to match a \n newline character, you must NOT double the slash in the pattern.

So, what is "any \ that you use" supposed to mean? Whether or not you need to double a slash clearly depends on what the slash is used for, so more context is needed.

You need to either state that more rigorously, or add more examples, or both.

And that's only for the pattern operand. I guess it gets even more subtle for the other  operand.

How to repeat:
...
[31 Aug 2020 21:22] MySQL Verification Team
Thank you for the bug report.
[11 Feb 2021 14:38] Paul DuBois
Posted by developer:
 
The statement refers to inclusion of a literal \ character.

MySQL uses C escape syntax in strings (for example, \n to represent
the newline character). If you want your expr or pat argument to
contain a literal \, you must double it.
[11 Feb 2021 15:02] teo teo
So why are you closing the report?