Line break in Javascript rule

How can i get a line break to  occur before and after the "Company Name" field when it is used and no line break when it is not used in  the data file?

stephensdirectAsked:
Who is Participating?
 
hieloCommented:
What does your data file look like? Knowing if the data is formatted a specific way will help produce a solution. EX: If your data set is formatted as follows:
Name: John Doe
Company: Company Name
Phone: 999-999-9999
The following would work:
var companyRE = /Company:\s*(.+)/g;
var companyName="";
var result =getData().match(companyRE);
if(result!=null)
{
  for( var i=1;i<result.length;++i)
   companyName += "\n"+result[i]+"\n";
}
NOTE: getData() is a function that is meat to return that data from which you want to extract the company name
0
 
LeeKowalkowskiCommented:
What do you mean by "when it is used" ?

--
Lee
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.