Regular Expressions 101

Community Patterns

js-create-includes-webpack-plugin regex

0

Regular Expression
PCRE (PHP <7.3)

/
\s*<script src="\/((\w+)[\w.\/]+)"><\/script>
/
g

Description

/**
 * WebPack plugin which replaces <script src="bundle.js"> to:
 *
 * <script>
 *   const bundleScript = document.createElement('script');
 *   bundleScript.type = 'text/javascript';
 *   bundleScript.async = true;
 *   bundleScript.src = 'bundle.js';
 *   document.body.appendChild(bundleScript);
 * </script>
 *
 * @package js-create-includes-webpack-plugin
 * @class   JSCreateIncludesWebpackPlugin
 * @author  Denis Efremov <efremov.a.denis@gmail.com>
 * @license MIT
 */
Submitted by anonymous - 5 years ago