League\CommonMark\Util\RegexHelper::unescape PHP Method

unescape() public static method

Replace backslash escapes with literal characters
public static unescape ( string $string ) : string
$string string
return string
    public static function unescape($string)
    {
        $allEscapedChar = '/\\\\(' . self::REGEX_ESCAPABLE . ')/';
        $escaped = preg_replace($allEscapedChar, '$1', $string);
        $replaced = preg_replace_callback('/' . self::REGEX_ENTITY . '/i', function ($e) {
            return Html5Entities::decodeEntity($e[0]);
        }, $escaped);
        return $replaced;
    }

Usage Example

 /**
  * Attempt to parse link title (sans quotes)
  *
  * @param Cursor $cursor
  *
  * @return null|string The string, or null if no match
  */
 public static function parseLinkTitle(Cursor $cursor)
 {
     if ($title = $cursor->match(RegexHelper::getInstance()->getLinkTitleRegex())) {
         // Chop off quotes from title and unescape
         return RegexHelper::unescape(substr($title, 1, strlen($title) - 2));
     }
 }
All Usage Examples Of League\CommonMark\Util\RegexHelper::unescape