This validator validates only if the value is at the beginning of a string.

@param mixed $word
@param bool  $identical

@return \NilPortugues\Validator\Attribute\String\StringAttribute
498676
public function startsWith($word, $identical = false)
    {
        $this->addCondition(__METHOD__, [$word, $identical]);

        return $this;
    }
1248722
protected function trimRep($word)
    {
        $lastChar  = null;
        $cleanWord = null;
        $max       = mb_strlen($word, 'UTF-8');
        
        for ($i = 0; $i < $max; $i++) {
            $char = mb_substr($word, $i, 1, 'UTF-8');
            if ($char != $lastChar) {
                $cleanWord .= $char;
            }
            $lastChar = $char;
        }
        
        return $cleanWord;
    }
518719
protected function wordMatchSupport( $newTagName, $attributes, $attributeString )
    {
        $ini = eZINI::instance( 'wordmatch.ini' );
        if ( $ini->hasVariable( $newTagName, 'MatchString' ) )
        {
            $matchArray = $ini->variable( $newTagName, 'MatchString' );
            if ( $matchArray )
            {
                foreach ( array_keys( $matchArray ) as $key )
                {
                    $matchString = $matchArray[$key];
                    if (  preg_match( "/$matchString/i", $attributeString ) )
                    {
                        $attributes['class'] = $key;
                        unset( $attributes['style'] );
                    }
                }
            }
        }
        return $attributes;
    }
1074251
private static function getR($word)
    {
        self::$R1 = "";
        self::$R2 = "";

        $vowels        = implode("", self::$vowels);
        $vowelGroup    = "[{$vowels}]";
        $nonVowelGroup = "[^{$vowels}]";
        // R1 is the region after the first non-vowel following a vowel, or is the null region at the end of the word if there is no such non-vowel.
        $pattern = "#(?P<rest>.*?{$vowelGroup}{$nonVowelGroup})(?P<r>.*)#u";
        if (preg_match($pattern, $word, $match)) {
            $rest = $match["rest"];
            $r1   = $match["r"];
            // [...], but then R1 is adjusted so that the region before it contains at least 3 letters.
            $cutOff = 3 - mb_strlen($rest);
            if ($cutOff > 0) {
                $r1 = mb_substr($r1, $cutOff);
            }
            self::$R1 = $r1;
        }

        //R2 is the region after the first non-vowel following a vowel in R1, or is the null region at the end of the word if there is no such non-vowel.
        if (preg_match($pattern, self::$R1, $match)) {
            self::$R2 = $match["r"];
        }
    }
679995
private function hasValidSEnding($word)
    {
        $lastLetter = Utf8::substr($word, -1, 1);
        return !in_array($lastLetter, array_merge(self::$vowels, array('j')));
    }
792019
public function getIrregularBase(Word $word) {
    if($base = $this->findIrregularBaseBehavior->getIrregularBase($word)) {
      return new Lemma($base, $this->getPartOfSpeechAsString());
    }

    return null;
  }
129099
public static function isPlural( $word, $returnSingular = false )
    {
        if ( empty( $word ) || !is_string( $word ) || strlen( $word ) < 3 )
        {
            return false;
        }

        $_temp = $word[strlen( $word ) - 1];

        if ( 's' == $_temp && $word == static::pluralize( substr( $word, 0, -1 ) ) )
        {
            if ( false !== $returnSingular )
            {
                return substr( $word, 0, -1 );
            }

            return true;
        }

        return false;
    }
1087851
public static function in($value, $haystack, $identical = false)
    {
        $haystack = (string) $haystack;
        $enc      = \mb_detect_encoding($value);

        if (false === $identical) {
            return (false !== \mb_stripos($haystack, $value, 0, $enc));
        }

        return (false !== \mb_strpos($haystack, $value, 0, $enc));
    }
858815
public function contains($value, $identical = false)
    {
        $this->addCondition(__METHOD__, [$value, $identical]);

        return $this;
    }
114665
public static function basedOnBlacklist($word)
	{
		$words[] = (string)$word;
		$words[] = strtolower($word);
		$words[] = strtolower(strrev($word));

		$len = strlen($word);
		$word2 = '';

		// @FIXME: badly inefficient
		for ($i = 0; $i < $len; $i++)
		{
			if (preg_match('/[a-zA-Z]/', $word[$i]))
			{
				$word2 .= $word[$i];
			}
		}

		$words[] = strtolower($word2);
		$words[] = strtolower(strrev($word2));
		$words[] = self::toL33t($word);
		$words[] = strrev(self::toL33t($word));
		$words[] = self::toSimpleL33t($word);
		$words[] = strrev(self::toSimpleL33t($word));

		$total = self::all()
			->whereIn('word', $words)
			->total();

		return ($total > 1); // returns true if char belongs to class
	}
925566
public function firstOf(string $name): Attribute
    {
        $attr = $this->_findFirst($name);
        if (!$attr) {
            throw new \UnexpectedValueException("No $name attribute.");
        }
        return $attr;
    }
714815
protected function stripTagAttributes($word)
    {
        $space = $this->stringUtil->strpos($word, ' ', 1);

        if ($space) {
            return '<' . $this->stringUtil->substr($word, 1, $space) . '>';
        }

        return trim($word, '<>');
    }
55811
public static function safe_ucfirst($seperator, $word) {
    # uppercase words split by the seperator (ex. dashes or periods)
    $parts = explode($seperator, $word);
    foreach ($parts as $word) {
      $words[] = (self::is_camel_case($word)) ? $word : ucfirst(strtolower($word));
    }
    return implode($seperator, $words);
  }
595862
public static function fix_case($word) {
    # Fix case for words split by periods (J.P.)
    if (strpos($word, '.') !== false) {
      $word = self::safe_ucfirst(".", $word);;
    }
    # Fix case for words split by hyphens (Kimura-Fay)
    if (strpos($word, '-') !== false) {
      $word = self::safe_ucfirst("-", $word);
    }
    # Special case for single letters
    if (strlen($word) == 1) {
      $word = strtoupper($word);
    }
    # Special case for 2-letter words
    if (strlen($word) == 2) {
      # Both letters vowels (uppercase both)
      if (in_array(strtolower($word{0}), self::$dict['vowels']) && in_array(strtolower($word{1}), self::$dict['vowels'])) {
        $word = strtoupper($word);
      }
      # Both letters consonants (uppercase both)
      if (!in_array(strtolower($word{0}), self::$dict['vowels']) && !in_array(strtolower($word{1}), self::$dict['vowels'])) {
        $word = strtoupper($word);
      }
      # First letter is vowel, second letter consonant (uppercase first)
      if (in_array(strtolower($word{0}), self::$dict['vowels']) && !in_array(strtolower($word{1}), self::$dict['vowels'])) {
        $word = ucfirst(strtolower($word));
      }
      # First letter consonant, second letter vowel or "y" (uppercase first)
      if (!in_array(strtolower($word{0}), self::$dict['vowels']) && (in_array(strtolower($word{1}), self::$dict['vowels']) || strtolower($word{1}) == 'y')) {
        $word = ucfirst(strtolower($word));
      }
    }
    # Fix case for words which aren't initials, but are all upercase or lowercase
    if ( (strlen($word) >= 3) && (ctype_upper($word) || ctype_lower($word)) ) {
      $word = ucfirst(strtolower($word));
    }
    return $word;
  }
1331601
public function underscore($word)
    {
        if (false !== stristr($word, '-')) {
            $parts = explode('-', $word);
            foreach ($parts as &$part) {
                $part = ucfirst(strtolower($part));
            }
            $word = implode('', $parts);
        }
        return strtolower(preg_replace('~(?<=\\w)([A-Z])~', '_$1', $word));
    }
974708
protected function match($pattern, $word)
    {
        if (substr($pattern, 0, 1) !== '-') // compare if the first byte is ascii `-`
        {
            return strcasecmp($pattern, $word) === 0 ? 0 : -1;
        }

        $matches = [];
        if (preg_match('/' . substr($pattern, 1) . '$/iu', $word, $matches)) {
            for ($i = count($matches) - 1; $i > 0; $i--) {
                $this->replacements[$i - 1] = $matches[count($matches) - $i];
            }

            return mb_strlen($word, 'UTF-8') - mb_strlen($matches[0], 'UTF-8');
        }

        return -1;
    }
197000
public function isPlural($word)
    {
        // Try the cache for an known inflection.
        $inflection = $this->getCachedSingular($word);

        if ($inflection !== false) {
            return true;
        }

        // Compute the inflection to cache the values, and compare.
        return $this->toPlural($this->toSingular($word)) == $word;
    }