Class ParsingUtility
- Namespace
- TMPEffects.TextProcessing
Utility methods for text processing and parsing.
public static class ParsingUtility- Inheritance
- 
      
      ParsingUtility
- Inherited Members
Methods
GetNextTag(string, int, ref TagInfo, TagType)
Get the next tag in text, starting from startIndex.
public static bool GetNextTag(string text, int startIndex, ref ParsingUtility.TagInfo tag, ParsingUtility.TagType type = TagType.Open | TagType.Close)Parameters
- textstring
- The full string. 
- startIndexint
- The index to start the search from. 
- tagParsingUtility.TagInfo
- Reference to a ParsingUtility.TagInfo. Will be set to the parsed tag if one is found. 
- typeParsingUtility.TagType
- The type of tag to get. Leave at default for either type. 
Returns
- bool
- true if a next tag was found; false otherwise. 
GetTagParametersDict(string)
Parses a string to a Dictionary<TKey, TValue>.
Pass in either a full tag string, e.g. <example=10 arg="value">, or the same but
without the brackets (example=10 arg="value").
Note that this only does some basic checks on the validity of the input string;
malformed strings may lead to errors.
Ideally use by passing in a parameterString.
public static Dictionary<string, string> GetTagParametersDict(string tag)Parameters
- tagstring
- The tag to parse the parameters of. 
Returns
- Dictionary<string, string>
- The parsed string as Dictionary<TKey, TValue>. 
Exceptions
IsTag(string, int, int, TagType)
Checks if the given string contains a substring starting at startIndex, going up to maxIndex, that is a well formed tag.
public static bool IsTag(string text, int startIndex, int maxIndex = -1, ParsingUtility.TagType type = TagType.Open | TagType.Close)Parameters
- textstring
- The string to check. 
- startIndexint
- The start index of the substring. 
- maxIndexint
- The end index of the substring. Leave at default to set to length of - text.
- typeParsingUtility.TagType
Returns
- bool
- true if the given string contains a substring starting at - startIndex, going up to- maxIndex, that is a well formed tag; otherwise false.
IsTag(string, TagType)
Checks if the given string is a well-formed tag (of the given type, if supplied).
public static bool IsTag(string tag, ParsingUtility.TagType type = TagType.Open | TagType.Close)Parameters
- tagstring
- The string to check. 
- typeParsingUtility.TagType
- The type of tag to check for. Leave default for either type. 
Returns
- bool
- true if the given string is a tag (of the given type, if supplied); otherwise false. 
TryParseTag(string, int, int, ref TagInfo, TagType)
Attempt to parse a tag from the substring of text given by startIndex and endIndex.
public static bool TryParseTag(string text, int startIndex, int endIndex, ref ParsingUtility.TagInfo tag, ParsingUtility.TagType type = TagType.Open | TagType.Close)Parameters
- textstring
- The full string. 
- startIndexint
- Start index of the substring. 
- endIndexint
- End index of the substring. 
- tagParsingUtility.TagInfo
- Reference to a ParsingUtility.TagInfo. Will be set to the parsed tag if successful. 
- typeParsingUtility.TagType
- The type of tag to check for. Leave at default for either type. 
Returns
- bool
- true if a tag was successfully parsed from the substring; false otherwise.