Regular Expressions 101

Find Angular-CLI <script src="*.bundle.js> injected elements

Open Workspace
  • PCRE (Legacy)
  • Match
0

Regular Expression

/
<\s*script\s+.+?(?=src\s*=\s*['"]).+?(?=.bundle.js).bundle.js\s*["'](?:\s*>|\s*\/\s*>)(?:\s*<\s*\/\s*script\s*>)?
/
ig

Description

Use Case Angular CLI adds in js bundles when a build is performed, one of the bundles are tiny and should be unlined.

Using something like gulp-replace that uses regedx to remove, and gulp-inject to rewrite these links ( and inline code ) can be very beneficial for a post build process if you are looking for an extra pagespeed score bump for SEO ranking etc.

Submitted by Anonymous