src/Translation/Language/Definition.php
/**
	 * Compiles the definition into a regular expression for quick matching or replacing.
	 *
	 * @return string
	 */
Compiles the definition into a regular expression for quick matching or replacing.
@return string
Compiles the definition into a regular expression for quick matching or replacing . @return string
public function compile() {
		if (!is_null($this->compiled)) {
			return $this->compiled;
		}
		if ($this->hasFlag('r')) {
			return $this->originalText;
		}
		$text = preg_replace("/({{\s*)([a-zA-Z._]+)(\s*}})/", "\\E{{\\s*\\Q$2\\E\\s*}}\\Q", $this->getOriginal());
		if ($this->hasFlag('x')) {
			$text = preg_replace("/(\s+)(?=(?:[^}]|{[^{]*})*$)/", "\\E\\s+\\Q", $text);
		}
		$pattern = '/(\\Q' . $text . '\\E)(?=(?:[^}]|{[^{]*})*$)/';
		if ($this->hasFlag('i')) $pattern .= 'i';
		$this->compiled = $pattern;
		return $pattern;
	}
public function compile ( ) { if ( ! is_null ( $ this -> compiled ) ) { return $ this -> compiled ; } if ( $ this -> hasFlag ( 'r' ) ) { return $ this -> originalText ; } $ text = preg_replace ( " /({{\s*)([a-zA-Z._]+)(\s*}})/ " , " \\ E{{ \\ s* \\ Q$2 \\ E \\ s*}} \\ Q " , $ this -> getOriginal ( ) ) ; if ( $ this -> hasFlag ( 'x' ) ) { $ text = preg_replace ( " /(\s+)(?=(?:[^}]|{[^{]*})*$)/ " , " \\ E \\ s+ \\ Q " , $ text ) ; } $ pattern = '/(\\Q' . $ text . '\\E)(?=(?:[^}]|{[^{]*})*$)/' ; if ( $ this -> hasFlag ( 'i' ) ) $ pattern .= 'i' ; $ this -> compiled = $ pattern ; return $ pattern ; }
Compiles the definition into a regular expression for quick matching or replacing.
Compiles the definition into a regular expression for quick matching or replacing .