Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

Remove Lines That Don't Contain Specific Text

Description
This macro searches text line by line, and removes any line that doesn't contain "google."
Language
C#.net
Minimum Version
Created By
Thomas Malloch (BFS)
Contributors
-
Date Created
Dec 17, 2015
Date Last Modified
Dec 17, 2015

Macro Code

using System;
using System.Text;

public static class ClipboardFusionHelper
{
	public static string ProcessText(string text)
	{
		//make sure all of the line breaks are the same
		//replace CRLF with LF
		text = text.Replace(Environment.NewLine, "\n");
		
		//replace CR with LF
		text = text.Replace("\r", "\n");
		
		//create a variable to store the edited text
		StringBuilder builder = new StringBuilder();
		
		//split the text up by the LF character ('\n') and loop through it
		foreach(string line in text.Split(new char[]{'\n'}, StringSplitOptions.RemoveEmptyEntries))
		{
			//if the line doesn't have the string "google" in it, ignore the line
			if(line.IndexOf("google", StringComparison.OrdinalIgnoreCase) == -1)
				continue;
				
			//add the line to the variable
			builder.AppendLine(line);
		}

		//return all of the lines that contain "google"
		return builder.ToString();
	}
}