0

So I've inherited some regular expressions I'm unfamiliar with and have been researching how they work. Sadly, I'm finding the documentation of Regular Expressions for MySQL is either limited, missing detailed information, or flat-out wrong; and standards from other platforms don't seem to be compatible. I'm hoping that somebody can help explain why this is, and also, if there's a site that properly documents everything for MySQL.

First, the below expression works great - it matches keywords from a table, but I'm putting "textdata" in as a placeholder since the problem is with the actual expression.

The Expression I'm having issues understanding is:

(?!\\B\\w)textdata(?<!\\w\\B)

So all the documentation says ? is used to define PROCEEDING character/string matching, and I can't find ! documented anywhere so I don't know what ?! translates to, or what ?<! translates to. On top of that the \B escape doesn't seem documented (and changing it to \b causes it to break, so it's case sensitive), and I'm assuming \w is word, but I'm also unsure of that. I can't seem to find any examples of these values being used anywhere in a properly documented format as they apply to MySQL.

Any help understanding this expression would be appreciated, and could/should it be rewritten in a different more "compatible" way?

Floobinator
  • 388
  • 2
  • 11
  • These are "adaptive" dynamic word boundaries, I linked to the thread where I explain what they match. – Wiktor Stribiżew Dec 14 '22 at 17:51
  • See mysql manual on regular expressions: https://dev.mysql.com/doc/refman/8.0/en/regexp.html#regexp-syntax `"The following list covers some of the basic special characters and constructs that can be used in regular expressions. For information about the full regular expression syntax supported by the ICU library used to implement regular expression support, visit the International Components for Unicode web site."` The last part is a link, where you can find the full documentation: https://unicode-org.github.io/icu/userguide/strings/regexp.html – Shadow Dec 14 '22 at 17:54
  • @Shadow thanks a ton - https://unicode-org.github.io/icu/userguide/strings/regexp.html is exactly what I was looking for, and I overlooked it in the MySQL documentation. – Floobinator Dec 14 '22 at 18:07
  • @WiktorStribiżew yup I found it, and read your explanation. Thanks! – Floobinator Dec 14 '22 at 18:07
  • Show examples of what should or should not match. – Rick James Dec 15 '22 at 18:36

0 Answers0