👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.
In JavaScript, how to check whether a string contains a line break?
The following checks whether a string contains a line break (\n
o r \r
) :
var str = "abc \n def";
if (/\r|\n/.exec(str)) {
}