Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

Below is the string i am getting

"One or more warnings have occurred. It is recommended that you follow the
instructions provided to correct the problem then try again.
-----------------------------------Information----------------------------------
Control Station: Check if standby is up
Information HC_CS_27389984778: The standby Control Station is
	 currently powered on. It will be powered off during upgrade, and then
	 later restarted and upgraded.
--------------------------------------------------------------------------------
------------------------------------Warnings------------------------------------
Blades : Check virus checker server configuration
Warning HC_DM_18800115743:
	 * vnxdm01: The virus checker configuration contains only one Virus
	   Checker (VC) server. High availability is compromised. It is
	   recommended to add at least a new VC server.
Action : Use the EMC Celerra AntiVirus MMC to add a new VC server
	 in the virus checker configuration, or edit the configuration
	 file manually.
--------------------------------------------------------------------------------"


i want this

------------------------------------Warnings------------------------------------
Blades : Check virus checker server configuration
Warning HC_DM_18800115743:
	 * vnxdm01: The virus checker configuration contains only one Virus
	   Checker (VC) server. High availability is compromised. It is
	   recommended to add at least a new VC server.
Action : Use the EMC Celerra AntiVirus MMC to add a new VC server
	 in the virus checker configuration, or edit the configuration
	 file manually.
--------------------------------------------------------------------------------"


Please let me know how to do this
Posted

Use a regex:
-+Warnings-+[^-]+-+
Should do it.
 
Share this answer
 
Comments
CPallini 8-Sep-15 3:11am    
Oh, those magic Regex!
5.
Arasappan 8-Sep-15 5:07am    
5
Following the example, a simple approach would be searching for the 'Warnings' line and then include in your result string all the remaining part.
e.g.
C#
public static string mytrim(string ins)
{
  string[] line = ins.Split(new char[] { '\n' }); // obtain an array of lines
  int n;
  for (n=0; n<line.Length; ++n)
  {
     if (line[n].Contains("-Warnings-")) // search for the 'Warnings' line
       break;
  }
  StringBuilder sb = new StringBuilder();
  for (; n < line.Length; ++n) // use the remaining (possibly empty) part for building the result string
  {
     sb.Append(line[n]);
     sb.Append("\n");
  }
  return sb.ToString();
}
 
Share this answer
 
Comments
Black_Rose 8-Sep-15 5:00am    
Hi CP.
Thanks for the reply.
This is working as expected.

One thing, can you tell me how to use the sb in dt.rows.add(). below is the code

mytrim(str_Final_Output); //calling your function
Obj_DT_FileHealthCheck.Rows.Add(ls_IP.ToString(), sb.ToString());
Black_Rose 8-Sep-15 5:10am    
Done that.

Thanks CP
CPallini 8-Sep-15 5:24am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900