CharacterCount

jdubs edited this page Oct 21, 2016 · 1 revision

Table of Contents

Overview

Returns the number of instances of a particular character or character set.

Parameters

SpecName (constant) The name of the variable for operation result assignment

Text (multiple) The variable containing the text to examine in the count operation

CharacterToFind (constant) The variable containing the text to find and count in the text

StartPosition (multiple) The starting position index in the text to begin searching. Default value is 0.

ErrorMessage (multiple | optional) The error message to return when any error occurs.

Synopsis

Counts the number of instances of the CharacterToFind input in the Text input then returns the result to a defined variable which may be used in other defined actions.

Source Code

public static void CharacterCount(string SpecName, object Text, object CharacterToFind, object StartPosition, object ErrorMessage)
{
	Break();
	try
	{
		var begin = ((string)Text).Length;
		var end = ((string)Text).Replace((string)CharacterToFind, String.Empty).Length;
		var result = begin - end;
		Variable(SpecName).Value = result.ToString();
	}
	catch (Exception ex)
	{
		throw new Four51ActionsException(ex.Message, (string)ErrorMessage);
	}
}

Referenced Methods

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.