Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
(?<![!=][=]{2})(?<=[^=][!=]=)(?![=U\/]|$)
/
img

Description

// @desc Replaces conditional operators with strict variant

/* Matches ==  */ if (e.keyCode ==  68) { doCode() }
/* Replacement */ if (e.keyCode === 70) { doCode() }
/* Problem !=  */ if (e.keyCode !=  69) { doCode() }
/* Replacement */ if (e.keyCode !== 71) { doCode() }
Submitted by disk0 - 5 years ago