MediaWiki  master
ResourceLoaderMwUrlModule.php
Go to the documentation of this file.
1 <?php
31  public static function makeJsFromExtendedRegExp( string $content ) : string {
32  // Remove whitespace.
33  $content = preg_replace( '/\s+/', '', $content );
34  // Remove named capturing groups.
35  // This allows long regexes to be self-documenting, which we allow for
36  // developer convenience, but this syntax is invalid JavaScript ES5.
37  $content = preg_replace( '/\?<\w+?>/', '', $content );
38  // Format as a valid JavaScript import.
39  return 'module.exports = /' . strtr( $content, [ '/' => '\/' ] ) . '/;';
40  }
41 }
ResourceLoaderMwUrlModule\makeJsFromExtendedRegExp
static makeJsFromExtendedRegExp(string $content)
Definition: ResourceLoaderMwUrlModule.php:31
$content
$content
Definition: router.php:76
ResourceLoaderMwUrlModule
Definition: ResourceLoaderMwUrlModule.php:25