RegexUtils class (Nixill.Utils)
Utilities and extension methods for working with Regex.
public static class RegexUtils
Static methods
TryMatch(string, string, out Match)
bool - Returns whether or not a match was successful, while also assigning the match.
Parameters:
stringinput- The input to test against the regex.stringpattern- The pattern against which input should be tested.out Matchmatch- When the method exits, this contains theMatchobject formed by the other two arguments (even if this method returnsfalse).
Returns: Whether or not match was successful.
Extension methods
Regex.TryMatch(string, out Match)
bool - Returns whether or not a match was successful, while also assigning the match.
Parameters:
this Regexregex- The regex to test matches against.stringinput- The input to test against the regex.out Matchmatch- When the method exits, this contains theMatchobject formed by the other two arguments (even if this method returnsfalse).
Returns: Whether or not match was successful.
Match.TryGroup(int, out string)
bool - Returns whether or not a group was successful, while also assigning the value.
Parameters:
this Matchmatch- The match to pull groups from.intnumber- Which group should be pulled.out stringvalue- When the method returnstrue, this contains the group’s value. If the method returnedfalse, this contains nothing.
Returns: Whether or not the group was successful.
Match.TryGroup(string, out string)
bool - Returns whether or not a group was successful, while also assigning the value.
Parameters:
this Matchmatch- The match to pull groups from.stringname- Which group should be pulled.out stringvalue- When the method returnstrue, this contains the group’s value. If the method returnedfalse, this contains nothing.
Returns: Whether or not the group was successful.