Comments containing macro defined in the post

0

Please login or register to vote for this query.

(click on this box to dismiss)

Craft CMS Meta

Q&A about the site for administrators, end users, developers and designers for Craft CMS

--We do not want the macro to be followed by alphanumerical character
--For example we want to match: \C but not \Cov, \norm but not \normalsize, \Q but not \quad
--thanks to rene for suggestion to use regex: https://chat.meta.stackexchange.com/transcript/1223/2019/2/1
SELECT TOP(##num?50##)
  c.Id AS [Comment Link], c.text, c.UserId AS [User Link], c.CreationDate
FROM Comments c JOIN Posts p ON c.PostId=p.Id
WHERE (c.Text LIKE '%[^\]\##text?Chi##[^a-zA-Z]%')
  AND NOT ((c.Text LIKE '%\newcommand{##text##}%')
    OR (c.Text LIKE '%\DeclareMathOperator{##text##}%')
    OR (c.Text LIKE '%\def{##text##}%'))
  AND ((p.Body LIKE '%\newcommand{\##text##}%')
    OR (p.Body LIKE '%\newcommand\##text##%')
    OR (p.Body LIKE '%\newcommand{##text##}%')
    OR (p.Body LIKE '%\renewcommand{\##text##}%')
    OR (p.Body LIKE '%\renewcommand\##text##%')
    OR (p.Body LIKE '%\renewcommand{##text##}%')
    OR (p.Body LIKE '%\DeclareMathOperator{\##text##}%')
    OR (p.Body LIKE '%\DeclareMathOperator{##text##}%')
    OR (p.Body LIKE '%\DeclareMathOperator\##text##%')
    OR (p.Body LIKE '%\def\##text##%'))
ORDER BY c.CreationDate DESC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results