Replaces {{CONSTANT}} with the value of constant, CONSTANT

@param string $sString The string to search on

@return string
516249
protected function replaceConstants($sString)
    {
        return preg_replace_callback(
            '/{{(.+?)}}/',
            function ($aMatches) {
                if (defined($aMatches[1])) {
                    return constant($aMatches[1]);
                }

                return $aMatches[0];
            },
            $sString
        );
    }
991409
function replaceInString(string, variables) {
    const model = createModel(string);
    let offset = 0;
    let output = '';

    for (let i = 0, il = model.variables.length; i < il; i++) {
        const v = model.variables[i];
        let value = v.name in variables ? variables[v.name] : v.name;
        if (typeof value === 'function') {
            value = value(model.string, v, offset + v.location);
        }

        output += model.string.slice(offset, v.location) + value;
        offset = v.location + v.length;
    }

    return output + model.string.slice(offset);
}
629562
public static ReplacedString replaceString(String s, String find, String replace) {
        if (replace == null) replace = "-";
        int index = -1;
        int l = find.length();
        boolean replaced = false;
        do {
            index = s.indexOf(find, index);
            if (index >= 0) {
                replaced = true;
                s = s.substring(0, index) + replace + s.substring(index + l);
            }
        } while (index >= 0);
        return new ReplacedString(s, replaced);
    }
735754
function _convertString($string)
    {
        // chop away beggining and ending quotes
        $string = substr($string, 1, strlen($string) - 2);
        if (strlen($string) > 255) {
            return $this->raiseError("String is too long");
        }

        if ($this->_BIFF_version == 0x0500) {
            return pack("CC", $this->ptg['ptgStr'], strlen($string)).$string;
        } elseif ($this->_BIFF_version == 0x0600) {
            $encoding = 0;   // TODO: Unicode support
            return pack("CCC", $this->ptg['ptgStr'], strlen($string), $encoding).$string;
        }
    }
808197
private function prepareString($string)
    {
        return str_replace(
            array_keys($this->owner->variables),
            array_values($this->owner->variables),
            $string
        );
    }
274291
private static String transform(String constantNameString)
    {
        StringBuilder sb = new StringBuilder();
        String tokens[] = constantNameString.split("_");
        List<String> list = new ArrayList<String>();
        for (String token : tokens)
        {
            String t = token.trim();
            if (!t.isEmpty())
            {
                list.add(t);
            }
        }
        for (int i=0; i<list.size(); i++)
        {
            if (i > 0)
            {
                sb.append(" ");
            }
            String t = list.get(i);
            sb.append(Character.toUpperCase(t.charAt(0)));
            sb.append(t.substring(1).toLowerCase());
        }
        return sb.toString();
    }
1081362
function (fromString) {
                    var matches = fromString.match(/(\${.*?})/g);
                    if (matches != null) {
                        for (var i = 0; i < matches.length; i++) {
                            var val = values[matches[i].substring(2, matches[i].length - 1)] || "";
                            if (val != null) {
                                fromString = fromString.replace(matches[i], val);
                            }
                        }
                    }
                    return fromString;
                }
1216256
protected function _getSearchSelect($sSearchString)
    {
        // check if it has string at all
        if (!$sSearchString || !str_replace(' ', '', $sSearchString)) {
            return '';
        }

        $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $sArticleTable = $this->getBaseObject()->getViewName();

        $aSearch = explode(' ', $sSearchString);

        $sSearch = ' and ( ';
        $blSep = false;

        // #723
        if ($myConfig->getConfigParam('blSearchUseAND')) {
            $sSearchSep = ' and ';
        } else {
            $sSearchSep = ' or ';
        }

        $aSearchCols = $myConfig->getConfigParam('aSearchCols');
        $myUtilsString = \OxidEsales\Eshop\Core\Registry::getUtilsString();
        foreach ($aSearch as $sSearchString) {
            if (!strlen($sSearchString)) {
                continue;
            }

            if ($blSep) {
                $sSearch .= $sSearchSep;
            }
            $blSep2 = false;
            $sSearch .= '( ';

            $sUml = $myUtilsString->prepareStrForSearch($sSearchString);
            foreach ($aSearchCols as $sField) {
                if ($blSep2) {
                    $sSearch .= ' or ';
                }

                // as long description now is on different table table must differ
                $sSearchTable = $this->getSearchTableName($sArticleTable, $sField);

                $sSearch .= $sSearchTable . '.' . $sField . ' like ' . $oDb->quote('%' . $sSearchString . '%') . ' ';
                if ($sUml) {
                    $sSearch .= ' or ' . $sSearchTable . '.' . $sField . ' like ' . $oDb->quote('%' . $sUml . '%');
                }
                $blSep2 = true;
            }
            $sSearch .= ' ) ';
            $blSep = true;
        }
        $sSearch .= ' ) ';

        return $sSearch;
    }
776995
private static function str_replace($s,$r,$str)
    {
        if(!is_array($s)){
            $s = '!'.preg_quote($s,'!').'!u';
        }else{
            foreach ($s as $k => $v) {
                $s[$k] = '!'.preg_quote($v).'!u';
            }
        }
        return preg_replace($s,$r,$str);
    }
1370732
public static function strIreplace($search, $replace, $str, $count = null, $encoding = null)
    {
        $encoding = $encoding === null ? mb_internal_encoding() : $encoding;

        if (!is_array($search)) {
            $slen = strlen($search);

            if ($slen == 0) {
                return $str;
            }

            $lendif = strlen($replace) - strlen($search);
            $search = static::strtolower($search, $encoding);
            $search = preg_quote($search, '/');
            $lstr = static::strtolower($str, $encoding);
            $i = 0;
            $matched = 0;

            while (preg_match('/(.*)' . $search . '/Us', $lstr, $matches)) {
                if ($count !== null && $i === $count) {
                    break;
                }

                $mlen = strlen($matches[0]);
                $lstr = substr($lstr, $mlen);

                $str = substr_replace($str, $replace, $matched + strlen($matches[1]), $slen);
                $matched += $mlen + $lendif;
                $i++;
            }

            return $str;
        } else {
            $keys = array_keys($search);

            foreach ($keys as $k) {
                if (is_array($replace)) {
                    if (array_key_exists($k, $replace)) {
                        $str = static::strIreplace($search[$k], $replace[$k], $str, $count, $encoding);
                    } else {
                        $str = static::strIreplace($search[$k], '', $str, $count, $encoding);
                    }
                } else {
                    $str = static::strIreplace($search[$k], $replace, $str, $count, $encoding);
                }
            }

            return $str;
        }
    }
1071099
private function normalize(string $string): string
    {
        return \str_replace($this->normalizeFrom, $this->normalizeTo, $string);
    }
1257454
public function StrReplace($search = ' ', $replace = '')
    {
        $owner = $this->owner;
        $owner->value = str_replace(
            $search,
            $replace,
            $owner->value
        );
        return $owner;
    }
293302
public function sanitizeString($string)
    {
        $string = str_replace('_', '-', GeneralUtility::camelCaseToLowerCaseUnderscored($string));

        while (strpos($string, '--')) {
            $string = str_replace('--', '-', $string);
        }

        return $string;
    }
1145419
private function getCommonPrefixString($left, $right)
    {
        for ($i = 1; $i < strlen($left); $i++) {
            if (substr_compare($left, $right, 0, $i) !== 0) {
                return substr($left, 0, $i - 1);
            }
        }
        return substr($left, 0, $i);
    }
1224864
function before( string $search ) : SplString
    {
        if( $search === '' ){
            return $this;
        } else{
            return $this->setString( explode( $search, $this->__toString() )[0] );
        }
    }
990979
private static function _encodeConstants(\ReflectionClass $cls)
    {
        $result    = "constants : {";
        $constants = $cls->getConstants();

        $tmpArray = array();
        if (!empty($constants)) {
            foreach ($constants as $key => $value) {
                $tmpArray[] = "$key: " . self::encode($value);
            }

            $result .= implode(', ', $tmpArray);
        }

        return $result . "}";
    }
1205328
protected function _isTranslateAble($sString)
    {
        $sPattern = $this->getTranslationPattern();
        $aMatches = array();
        if (is_array($sString)) {
            $sString = implode('_DELIMITER_', $sString);
        }
        preg_match_all("|{$sPattern}|", $sString, $aMatches);

        if ($aMatches['key'] > 0) {
            $this->_setKeys($aMatches['key']);
            return true;
        }
        return false;
    }