Prepares a string for xpath expression with the condition [text()=].

@param  String  string
@return String
343476
function quoteXPathAttributeString(string) {
    "use strict";
    if (/"/g.test(string)) {
        return 'concat("' + string.toString().replace(/"/g, '", \'"\', "') + '")';
    } else {
        return '"' + string + '"';
    }
}
1007626
public static function prepare(string $string, $quotes = '/') : string
    {
        $string = $quotes ? preg_quote($string, $quotes) : $string;

        return str_replace(
            array_keys(self::REGEX_CHARS_REPLACEMENT),
            array_values(self::REGEX_CHARS_REPLACEMENT),
            $string
        );
    }
1025753
public static void waitUntilTextPresent(final String searchString) {
        logger.entering(searchString);
        Preconditions.checkArgument(StringUtils.isNotEmpty(searchString), "Search string cannot be null (or) empty.");
        ExpectedCondition<Boolean> conditionToCheck = new ExpectedCondition<Boolean>() {
            @Override
            public Boolean apply(WebDriver input) {
                return getTextFromBody().contains(searchString);
            }
        };
        waitForCondition(conditionToCheck);
        logger.exiting();
    }
1339199
public function parseString($string)
    {
        $string = (string) $string;
        $string = preg_replace_callback("/\\$\{(.*?)\}/",
            function ($k) {
                return $this->get($k[1]);
            }, $string);

        return $string;
    }
1181870
public String stripHtmlTags(String string)
    {
        for (int i = 1; i < string.length(); i++)
        {
            if (string.charAt(i) == '<')
            {
                int iEndTag = string.indexOf('>', i);
                if (iEndTag != -1)
                {
                    string = string.substring(0, i) + JAVA_NEW_LINE + string.substring(iEndTag + 1);
                    i--;
                }
            }
        }
        return string;
    }
839084
public String patternToRegex(String string)
    {
        if (string != null)
            if (!string.contains("["))
                 if (!string.contains("{"))  // If it has one of these, it probably is a regex already.
                     if (!string.contains("\\."))
        {
            string = string.replace(".", "\\.");
            string = string.replace("*", ".*");
        }
        return string;
    }
447695
private function prepareMessage(string $string): string
    {
        if (Translator::isMessage($string)) {
            $string = substr($string, 2, -2);
        }

        return $string;
    }
1098695
public static function parse($string)
    {
        if (static::isJSON($string)) {
            $result = static::jsonDecode($string);
        } elseif (static::isXML($string)) {
            $result = static::xmlDecode($string);
        } else {
            throw new \InvalidArgumentException(sprintf('Unable to parse: %s', (string) $string));
        }

        return (array) $result;
    }
162895
public function parseString($string)
    {
        //argument 1 must be a string
        Argument::i()->test(1, 'string');
        
        foreach ($this->data as $key => $value) {
            $string = str_replace($key, $value, $string);
        }

        return $string;
    }
1001493
public static function assertEqualsRegExp($compare, $string)
    {
        if (is_array($compare)) {
            $compare = implode('{{ \s* }}', $compare);
            $compare = str_replace(array('{{ \s* }}{{ ', ' }}{{ \s* }}'), array('{{ ', ' }}'), $compare);
        }
        if (empty($compare)) {
            return self::assertEquals($compare, $string);
        }
        $string = trim(str_replace(array("\r", "\n", "\t"), '', $string));
        $error = $string;
        preg_match_all('/{{\s[^\}]*\s}}/', $compare, $regexp);
        $equals = preg_split('/{{\s[^\}]*\s}}/', $compare);
        foreach ($equals as $key => $value) {
            if (!empty($value)) {
                try {
                    self::assertEquals($value, substr($string, 0, strlen($value)));
                } catch (\Exception $e) {
                    self::fail(implode("\n", array(
                        $e->getMessage(),
                        '--- Expected',
                        '+++ Actual',
                        '@@ @@',
                        self::merge(array_slice($equals, 0, $key, true), $regexp[0]),
                        '',
                        "-'".$value."'",
                        "+'".$string."'",
                    )));
                }
                $string = substr($string, strlen($value));
            }
            $next = (isset($equals[$key + 1])) ? $equals[$key + 1] : '';
            $length = (!empty($next)) ? strpos($string, $next) : 0;
            if (isset($regexp[0][$key]) && $length !== false) {
                $pattern = substr($regexp[0][$key], 3, -3);
                try {
                    self::assertRegExp('/^'.$pattern.'$/', substr($string, 0, $length));
                } catch (\Exception $e) {
                    if ('{{ '.$pattern.' }}' == substr($string, 0, $length)) {
                        // a literal (string) match
                    } else {
                        self::fail(implode("\n", array(
                            self::merge(array_slice($equals, 0, $key, true), $regexp[0]),
                            '',
                            $e->getMessage(),
                            $value.$regexp[0][$key].$next,
                            '',
                            self::merge(array_slice($equals, $key + 2, null, true), $regexp[0]),
                        )));
                    }
                }
                $string = substr($string, $length);
            }
        }
        if (!empty($string)) {
            return self::assertEquals(strstr($error, $string, true), $error);
        }
    }
1157427
private String processText(String text) {
        String rslt = text; // default
        Expression x =
                portalSpELService.parseExpression(
                        text, PortalSpELServiceImpl.TemplateParserContext.INSTANCE);
        rslt = x.getValue(ctx, String.class);
        return rslt;
    }
581990
public function prepare($text, $length = 100, $endString = '...')
    {
        $substring = strip_tags(preg_replace('/<br.?\/?>/', ' ',$text));
        $textLength = mb_strlen($substring);
        
        if($textLength > $length) {
            $lastWordPosition = mb_strpos($substring, ' ', $length);
            
            if($lastWordPosition) {
                $substring = mb_substr($substring, 0, $lastWordPosition);
            } else {
                $substring = mb_substr($substring, 0, $length);
            }
            
            $substring.= $endString;
        }
        
        return $substring;
    }
1116139
public static Condition exactTextCaseSensitive(final String text) {
    return new Condition("exact text case sensitive") {
      @Override
      public boolean apply(Driver driver, WebElement element) {
        return Html.text.equalsCaseSensitive(element.getText(), text);
      }

      @Override
      public String toString() {
        return name + " '" + text + '\'';
      }
    };
  }
696732
protected function prepareMysqlRegexp($string)
    {
        $regexp = $string;

        // first remove trailing increment
        $regexp = preg_replace('/\([0-9]\)$/', "", $regexp);

        // escape existing parenthesis
        $regexp = preg_replace('(\(|\))', '\\\\${0}', $regexp);

        // append matching mysql matching pattern
        $regexp .= "([[.left-parenthesis.]][0-9]*[[.right-parenthesis.]])*$";

        return $regexp;

    }
17695
protected function operandi($string, $set = false, $prepared = false) {
        if(empty($string) && $string !== "0") {
            return ($set ? ' = NULL' : ' IS NULL');
        }

        $firstLetter = strtolower(substr($string, 0, 1));
        switch($firstLetter) {
            case '>':
            case '<':
                $return = ' ' . $firstLetter . ' "' . intval(substr($string, 1)) . '"';
                break;
            case '.':
                $return = ' = NOW()';
                break;
            case '$':
                $rest = substr($string, 1);
                if($prepared){
                    $return = ' = UNHEX(?)';
                    $this->addExclusion($rest, 's');
                } else {
                    $return = ' = UNHEX("'.$rest.'")';
                }
                break;
            case '!':
                if(strtolower($string) == '!null' || strlen($string) == 1){
                    if($set){
                        $this->formatError(
                            [$string], 'Cannot set "NOT NULL" as value for "' . substr($string, 1) . '"'
                        );
                    }
                    $return = ' IS NOT NULL ';
                } else {
                    if($set){
                        $this->formatError([$string], 'Cannot use "!= ' . substr($string, 1) . '" to set a value');
                    }
                    $return = ' != "' . substr($string, 1) . '"';
                }
                break;
            case '{':
                $return = ' ' . substr($string, 1, -1);
                break;
            case '^':
                $return = ($set ? ' = NULL' : ' IS NULL');
                break;
            default:
                if(strtolower($string) == 'null'){
                    $return = ($set ? ' = NULL' : ' IS NULL');
                } elseif($prepared){
                    $return = ' = ? ';
                    $this->addExclusion($string);
                } else {
                    $return = ' = "' . $string . '"';
                }
                break;
        }
        return $return;
    }
1142004
public static function clean($string): string
    {
        $string = trim($string);
        $string = htmlspecialchars($string);
        return $string;
    }
523795
private static function PrepareRegexFlags( $flagString )
	{
		// The flag string can only contain s,m,i and/or x
		$result = preg_match( "/[^smix]+/", $flagString);
		if ( $result )
		{
			throw XPath2Exception::withErrorCodeAndParam( "FORX0001", Resources::InvalidRegularExpr, "$flagString" );
		}

		return $flagString;
	}