77 private ?
string $mBaseRegex =
null;
96 $this->mSynonyms = (array)$syn;
97 $this->mCaseSensitive = $cs;
109 $this->contLang->getMagic( $this );
110 if ( !$this->mSynonyms ) {
111 throw new MWException(
"Error: invalid magic word '$id'" );
132 return $this->mCaseSensitive ?
'' :
'iu';
160 if ( $this->mBaseRegex ===
null ) {
164 usort( $synonyms,
static fn ( $a, $b ) => strlen( $b ) <=> strlen( $a ) );
165 foreach ( $synonyms as &$synonym ) {
166 $synonym = preg_quote( $synonym,
'/' );
168 $this->mBaseRegex = implode(
'|', $synonyms );
170 return $this->mBaseRegex;
181 return (
bool)preg_match( $this->
getRegex(), $text );
205 $text = preg_replace( $this->
getRegex(),
'', $text, -1, $count );
214 $text = preg_replace( $this->
getRegexStart(),
'', $text, -1, $count );
227 public function replace( $replacement, $subject, $limit = -1 ) {
230 StringUtils::escapeRegexReplacement( $replacement ),
245 return $this->mSynonyms[$i];
273class_alias( MagicWord::class,
'MagicWord' );
Base class for language-specific code.
A collection of static methods to play with strings.