Quote regular expression characters.

@return string
166841
private function escapeTemplate($value) {
        $result = $value;

        $result = str_replace('{{', chr(1), $result);
        $result = str_replace('}}', chr(2), $result);

        $result = preg_replace_callback('/([^\{\/\x5c]+|)(\{[^\}]+\})([^\{\/\x5c]+|)/', function($m) {
            array_shift($m);

            $m = array_filter($m, function($item) {
                return !empty($item);
            });

            $m = array_map(function($item) {
                return mb_substr($item, 0, 1) !== '{' ? preg_quote($item, '/') : $item;
            }, $m);

            return implode('', $m);
        }, $result);

        $result = str_replace(chr(1), '\\{', $result);
        $result = str_replace(chr(2), '\\}', $result);

        return $result;
    }
108497
protected function _quoteValue($value)
    {
        if(is_numeric($value)) {
            return false;
        }

        if(strpos($value, $this->separator) !== false) { // Separator is present in field
            return true;
        }

        if(strpos($value, $this->quote) !== false) { // Quote character is present in field
            return true;
        }

        if (strpos($value, "\n") !== false || strpos($value, "\r") !== false ) { // Newline is present in field
            return true;
        }

        if(substr($value, 0, 1) == " " || substr($value, -1) == " ") {  // Space found at beginning or end of field value
            return true;
        }

        return false;
    }
740190
public function quoteValue($str)
    {
        if (is_int($str) || is_float($str)) {
            return $str;
        }

        return "'" . addcslashes(str_replace("'", "''", $str), "\000\n\r\\\032") . "'";
    }
225956
public function getAsString(): string
    {
        $text = $this->source->getAsString();

        $stripAll = new StripAllFilter();
        $htmlFilter = new HtmlFilter();

        /* Removing CDATA tags */
        $text = preg_replace_callback(
            '#<!\[CDATA\[(.*?)\]\]>#ums',
            function ($match) use ($htmlFilter) {
                $string = $htmlFilter->filter($match[1]);

                //      <![CDATA[               ]]
                return '         ' . $string . '  ';
            },
            $text
        );

        /* Processing bottom level tags */
        $text = preg_replace_callback(
            '#(<(\w+)(\s[^>]*?)?>)([^<>]*)(</\w+\s*>)#um',
            function ($match) use ($stripAll) {
                if (strtolower($match[2]) === 'target') {
                    $replace = $stripAll->filter($match[1]) . $match[4]
                        . $stripAll->filter($match[5]);
                } else {
                    $replace = $stripAll->filter($match[0]);
                }

                return $replace;
            },
            $text
        );

        /* Other replacements */
        foreach ($this->filters as $pattern => $filter) {
            if (null === $filter) {
                $filter = $stripAll;
            }
            $text = preg_replace_callback(
                $pattern,
                function ($match) use ($filter) {
                    return $filter->filter($match[0]);
                },
                $text
            );
        }

        return $text;
    }
362121
public function getRegexp()
	{
		$hosts = [];
		foreach ($this->items as $host)
		{
			$hosts[] = $this->normalizeHostmask($host);
		}

		$regexp = RegexpBuilder::fromList(
			$hosts,
			[
				// Asterisks * are turned into a catch-all expression, while ^ and $ are preserved
				'specialChars' => [
					'*' => '.*',
					'^' => '^',
					'$' => '$'
				]
			]
		);

		return '/' . $regexp . '/DSis';
	}
1304067
private function quoteApplicationName($s) {
	    $quotedString = $this->collapseWhitespace($s);
	    $quotedString = preg_replace('/\\\\/', '\\\\\\\\', $quotedString);
	    $quotedString = preg_replace('/\//', '\\/', $quotedString);
	
	    return $quotedString;
    }
1320187
def _quote_escape(item):
    '''
    
    '''

    rex_sqlquote = re.compile("'", re.M)

    return rex_sqlquote.sub("''", item)
1121778
function quote(s) {
    if (typeof(s) === 'string') {
        return "'" + s.replace(/'/g, "''") + "'";
    } else if (s instanceof Array) {
        return _.map(s, quote).join(', ');
    }

    return s;
}
602295
private String escapeQuotes(String value)
   {
      StringBuilder sb = new StringBuilder();
      int length = value.length();
      char c;

      sb.append('"');
      for (int index = 0; index < length; index++)
      {
         c = value.charAt(index);
         sb.append(c);

         if (c == '"')
         {
            sb.append('"');
         }
      }
      sb.append('"');

      return (sb.toString());
   }
1031149
public function getAsString(): string
    {
        return implode(
            '_',
            array_filter([
                (string) $this->getLanguage(),
                (string) $this->getRegion(),
                (string) $this->getScript(),
            ])
        );
    }
1353167
def url_quote(s, charset='utf-8', safe='/:'):
    
    if isinstance(s, unicode):
        s = s.encode(charset)
    elif not isinstance(s, str):
        s = str(s)
    return _quote(s, safe=safe)
1008943
protected function getRegexp()
	{
		$anchor = RegexpBuilder::fromList($this->configurator->urlConfig->getAllowedSchemes()) . '://';
		if ($this->matchWww)
		{
			$anchor = '(?:' . $anchor . '|www\\.)';
		}

		$regexp = '#\\b' . $anchor . '\\S(?>[^\\s()\\[\\]'
		        . '\\x{FF01}-\\x{FF0F}\\x{FF1A}-\\x{FF20}\\x{FF3B}-\\x{FF40}\\x{FF5B}-\\x{FF65}'
		        . ']|\\([^\\s()]*\\)|\\[\\w*\\])++#Siu';

		return $regexp;
	}
492159
public function _quote($str)
	{
		// Check that the current value is a string,
		// and is not already quoted before quoting
		// that value, otherwise, return the original value
		return (
			\is_string($str)
			&& strpos($str, $this->escapeCharOpen) !== 0
			&& strrpos($str, $this->escapeCharClose) !== 0
		)
			? "{$this->escapeCharOpen}{$str}{$this->escapeCharClose}"
			: $str;

	}
999349
public function quote($value)
    {
        if (is_array($value)) {
            $result = [];
            foreach ($value as $single) {
                $result[] = $this->quote($single);
            }
            return sprintf(
                '(%s)',
                implode(', ', $result)
            );
        } else {
            return $this->pdo->quote($value);
        }
    }
7308
def latex_quote(s):
    
    special = {'_':r'\_', '$':r'\$', '#':r'\#'}
    s = str(s)
    for char,repl in special.items():
        new = s.replace(char, repl)
        s = new[:]
    return s
417750
public function character()
    {
        $rows = [];
        $rows[] = ' ' . str_repeat('-', $this->width);
        for ($y = 0; $y < $this->height; $y++) {
            $row = '|';
            for ($x = 0; $x < $this->width; $x++) {
                $row .= $this->space($x, $y)->character();
            }
            $row .= '|';
            $rows[] = $row;
        }
        $rows[] = ' ' . str_repeat('-', $this->width);
        return implode("\n", $rows) . "\n";
    }
463223
function quote($value)
  {
    if ($value === null)
      return 'null';

    assert (!is_object($value));

    if (is_bool($value))
      return (int) $value;

    // Protect digit sequences beginning with '0' (eg phone numbers)
    if (is_string($value) && substr($value, 0,1) == "0")
     return "'".$this->real_escape_string($value)."'";

    if (is_numeric($value))
      return $value;

    // Create comma separated lists for arrays.
    if (is_array($value))
    {
      $res = [];
      foreach ($value as $v)
      {
        if (is_array($v))
          $res[] = "(".$this->quote($v).")";
        else
          $res[] = $this->quote($v);
      }
      return implode(",",$res);
    }

    return "'".$this->real_escape_string($value)."'";
  }