Regular Expressions 101

Community Patterns

Smart Target Blank

3

Regular Expression
ECMAScript (JavaScript)

/
\.(?!html?)([a-z]{0,3}|[a-z]{0,4})$
/
gm

Description

Allow you to check if the JavaScript location.pathname is a link required adding a target="_blank".

Submitted by Bruno Lesieur - 9 years ago