Table of Contents

Class FormatOfString

Namespace
SunamoText
Assembly
SunamoText.dll

Provides methods for parsing and validating string formats using pipe-delimited templates. Alternatives: TextFormatData - can check whether on position is expected char (letter, digit, etc.) but then not allow variable length of parsed.

public class FormatOfString
Inheritance
FormatOfString
Inherited Members
Extension Methods

Methods

GetParsedParts(string, string)

Parses variable parts from text using pipe-delimited format. For example, format "{Width=|, Height=|}" applied to "{Width=100, Height=200}" returns ["100", "200"].

public static List<string> GetParsedParts(string text, string format)

Parameters

text string

The input text to parse.

format string

The pipe-delimited format template where | marks variable parts.

Returns

List<string>

List of parsed variable parts, or empty list if format does not match.

HasFormat(string, string, bool)

Checks whether text matches the given pipe-delimited format.

public static bool HasFormat(string text, string format, bool isUsingWildcard = false)

Parameters

text string

The input text to validate.

format string

The pipe-delimited format template.

isUsingWildcard bool

When true, pipes are replaced with wildcards for pattern matching.

Returns

bool

True if the text matches the format; otherwise false.