👋 Hello! I'm Alphonsio the robot. Ask me a question, I'll try to answer.

javascript check for line break string

The following checks whether a string contains a line break (\n o r \r) :

var str = "abc \n def";
if (/\r|\n/.exec(str)) {
	// Do something, the string contains a line break

}

More