$('pre:contains("\n")') will select all <pre> which contain at least one newline.
How to select all <pre> which contains no newline or only one newline at the end?
What’s the quick way?
match
<pre>A</pre>
<pre>B
</pre>
not match
<pre>C
</pre>
<pre>
D</pre>
<pre>
E
</pre>
Perhaps simple approach would suffice, trimmed the text then detect newline:
Sample data:
Outputs:
Live test: http://jsfiddle.net/Anb6q/1/