# How to detect line break in a String using UnityScript?

Code:

var i:int=0;
var text:String;
var compare:String="";
var isFound:boolean=false;
function Start(){
}

function Update(){
if(!found)
com("textToSearch");
}

function com(s:String){
if(i<text.Length){
comText=comText+text[i];
if(//condition for line break)
if(comText==s){
print("found");
found=true;
}
else{
comText="";
}
i++;
}

}


In the text document each word ends with a line break. So if I just found a condition for a line break then I can easily search through the document.

if(myLine.Contains("\n")){

• FWIW, myLine.Contains("\n") will return true anytime myLine.Contains("\r\n") does, so, myLine.Contains("\r\n") is completely unnecessary. Jul 21 '17 at 14:37