While anyone will explore this question, the obvious question arises that, is there any regular expression possible that matches
${foo}
but not
<c:if test="${foo}" />
or
<c:when test="${foo}" />
to replace those stand alone ${foo} with <c:out value="${foo}" />, here foo can be any string as long as ${foo} is a valid el expression in jsp.
Edit:
${foo} can be anywhere as long as its not violating jsp syntax after the replacement! This is just a precaution to prevent XXS attack in jsp's.

