Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
<\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 - 8 years ago