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