Scan tree for occurences of the given substring.

@param  string  $pSubstring String to check whether it is contained or not
@return integer             Returns 1 if found, -1 if not
554553
public function hasSubstring( $pSubstring ) {
        if ( strlen( $pSubstring ) < 1 ) {
            return -1;
        }

        return $this->findSubstring( $this->nodes[$this->root], $pSubstring );
    }
985844
public static function substringBefore($string, $separator)
    {
        $pos = mb_strpos($string, $separator);
        return $pos !== false ? mb_substr($string, 0, $pos) : $string;
    }
736737
def _findOne(self, subString):
        
        SA = self.SA
        LCPs = self._LCP_values
        string = self.string

        try:
            subString = _array("i", [self.tokId[c] for c in self.tokenize(subString)])
        except KeyError:
            # if a token of the subString is not in the vocabulary
            # the substring can't be in the string
            return False
        lenSubString = len(subString)

        #################################
        # Dichotomy search of subString #
        #################################
        lower = 0
        upper = self.length
        success = False

        while upper - lower > 0:
            middle = (lower + upper) // 2

            middleSubString = string[SA[middle]:min(SA[middle] + lenSubString, self.length)]

            # NOTE: the cmp function is removed in Python 3
            # Strictly speaking we are doing one comparison more now
            if subString < middleSubString:
                upper = middle
            elif subString > middleSubString:
                lower = middle + 1
            else:
                success = True
                break

        if not success:
            return False
        else:
            return middle
83539
public function detect($string, $inBlock = false)
    {
        if (empty($string)) {
            return (false);
        }
        if (
            substr_compare($string, '[[[', 0, 3) === 0 ||
            substr_compare($string, '<<<', 0, 3) === 0 ||
            substr_compare($string, '{{{', 0, 2) === 0 ||
            substr_compare($string, '||', 0, 2) === 0 ||
            substr_compare($string, '!!', 0, 2) === 0
        )
            return (false);
        if (!preg_match("/^\s*\*{2}.*\*{2}\s*.*$/", $string) &&
            !preg_match("/^\s*#{2}.*#{2}\s*.*$/", $string) &&
            preg_match("/^\s*[\*#\- \t>;=].*/", $string)
        ) {
            return (false);
        }
        $this->_detectMatch = array($string, $string);
        return (true);
    }
194912
private function isJsonMercureFormat(string $string):int
    {
        $len =  strlen($string);

        if ($len > 3 && ($string[0] == "{" && $string[$len - 1] == "}")) {
            $string = str_replace("{", "", $string);
            $string = str_replace("}", "", $string);
            $r = explode(',', $string);
            return (!in_array(" ", $r))? 1 : 0;
        }
        return (0);
    }
1323315
public function ensureRight($substring)
    {
        if ($this->endsWith($substring))
        {
            return $this;
        }
        else
        {
            return $this->newSelf($this->scalarString.$substring);
        }
    }
319974
public function detect($string, $inBlock = false)
    {
        if (!preg_match($this->regexp, $string, $this->_detectMatch)) {
            return (0);
        }

        return (1);
    }
640195
public static function columnIndexFromString($pString = 'A')
	{
		//	Using a lookup cache adds a slight memory overhead, but boosts speed
		//	caching using a static within the method is faster than a class static,
		//		though it's additional memory overhead
		static $_indexCache = array();

		if (isset($_indexCache[$pString]))
			return $_indexCache[$pString];

		//	It's surprising how costly the strtoupper() and ord() calls actually are, so we use a lookup array rather than use ord()
		//		and make it case insensitive to get rid of the strtoupper() as well. Because it's a static, there's no significant
		//		memory overhead either
		static $_columnLookup = array(
			'A' => 1, 'B' => 2, 'C' => 3, 'D' => 4, 'E' => 5, 'F' => 6, 'G' => 7, 'H' => 8, 'I' => 9, 'J' => 10, 'K' => 11, 'L' => 12, 'M' => 13,
			'N' => 14, 'O' => 15, 'P' => 16, 'Q' => 17, 'R' => 18, 'S' => 19, 'T' => 20, 'U' => 21, 'V' => 22, 'W' => 23, 'X' => 24, 'Y' => 25, 'Z' => 26,
			'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5, 'f' => 6, 'g' => 7, 'h' => 8, 'i' => 9, 'j' => 10, 'k' => 11, 'l' => 12, 'm' => 13,
			'n' => 14, 'o' => 15, 'p' => 16, 'q' => 17, 'r' => 18, 's' => 19, 't' => 20, 'u' => 21, 'v' => 22, 'w' => 23, 'x' => 24, 'y' => 25, 'z' => 26
		);

		//	We also use the language construct isset() rather than the more costly strlen() function to match the length of $pString
		//		for improved performance
		if (isset($pString{0})) {
			if (!isset($pString{1})) {
				$_indexCache[$pString] = $_columnLookup[$pString];
				return $_indexCache[$pString];
			} elseif(!isset($pString{2})) {
				$_indexCache[$pString] = $_columnLookup[$pString{0}] * 26 + $_columnLookup[$pString{1}];
				return $_indexCache[$pString];
			} elseif(!isset($pString{3})) {
				$_indexCache[$pString] = $_columnLookup[$pString{0}] * 676 + $_columnLookup[$pString{1}] * 26 + $_columnLookup[$pString{2}];
				return $_indexCache[$pString];
			}
		}
		throw new PHPExcel_Exception("Column string index can not be " . ((isset($pString{0})) ? "longer than 3 characters" : "empty"));
	}
912490
public static int substr_count(final String string, final String substring) {
        if(substring.length()==1) {
            return substr_count(string, substring.charAt(0));
        }
        
        int count = 0;
        int idx = 0;

        while ((idx = string.indexOf(substring, idx)) != -1) {
           ++idx;
           ++count;
        }

        return count;
    }
1331950
protected function scanPyStringContent()
    {
        if (!$this->inPyString) {
            return null;
        }

        $token = $this->scanText();
        // swallow trailing spaces
        $token['value'] = preg_replace('/^\s{0,' . $this->pyStringSwallow . '}/u', '', $token['value']);

        return $token;
    }
1353705
public function getStringPositionSql($substring, $string)
	{
		$this->connect();

		$query = "SELECT POSITION( $substring IN $string )";
		$this->setQuery($query);
		$position = $this->loadRow();

		return $position['position'];
	}
766015
public static function substring($string = false, $firstIndex = 0, $maxStringLength = false) {

        if ($string) {

            if (!$maxStringLength) {

                $maxStringLength = (self::length($string) - $firstIndex);
            }

            return substr($string, $firstIndex, $maxStringLength);
        }

        return false;
    }
133071
private boolean doesModulePathIncludeSubstring(ModuleNode moduleNode, final String substring) {

        if (moduleNode == null) {
            return false;
        }

        boolean substringFoundInDescription = false;
        String commandObjectModuleDescription = moduleNode.getDescription();
        if (commandObjectModuleDescription != null) {
            substringFoundInDescription = commandObjectModuleDescription.contains(substring);
        }
        return substringFoundInDescription;
    }
1339212
public static function substrCount(
        $string,
        $search,
        $caseSensitive = true,
        $encoding = null
    ) {
        $encoding = $encoding === null ? mb_internal_encoding() : $encoding;

        if (!$caseSensitive) {
            $string = static::strtoupper($string);
            $search = static::strtoupper($search);
        }

        return mb_substr_count($string, $search, $encoding);
    }
493306
public boolean contains(final UTF8String substring) {
    if (substring.numBytes == 0) {
      return true;
    }

    byte first = substring.getByte(0);
    for (int i = 0; i <= numBytes - substring.numBytes; i++) {
      if (getByte(i) == first && matchAt(substring, i)) {
        return true;
      }
    }
    return false;
  }
928660
function Check($value)
    {
        $success = true;
        $strings = System\Str::SplitLines($value);
        foreach ($strings as $string)
        {
            $success = parent::Check($string);
            if (!$success)
                break;
        }
        
        //The value is temporarily set to the substrings
        //when calling the parent check function above,
        //so we have to store it here, not before the loop:
        $this->SetValue($value);
        return $success;
    }
377280
public function isSerialized($string)
    {
        if (!is_string($string)) {
            return false;
        }

        if ($string === 'N;') {
            return true;
        }

        if (strlen($string) < 4) {
            return false;
        }

        if ($string[1] !== ':') {
            return false;
        }

        if (!in_array($string[0], ['s', 'a', 'O', 'b', 'i', 'd'])) {
            return false;
        }

        return @unserialize($string) !== false;
    }