?@\[\\\\\]^_`{|}~]'; /** * Replace each `\X` (where X is GFM-escapable ASCII punctuation) * with the literal X. */ public static function unescapeBackslashes(string $text): string { // Paired `{...}` delimiters: PHP single-char delimiters (`/`, `~`, // `#`) appearing inside the regex terminate it early. Every char // we'd want as a delimiter is in our escapable class, so we use // the paired form — PCRE treats `}` as the closer only at the // outermost level, not inside the `[...]` class. return preg_replace( '{\\\\(' . self::PUNCTUATION_CHAR_CLASS . ')}', '$1', $text ); } }