Method TimeSpanRegex
- Namespace
- DisCatSharp.Common.RegularExpressions
- Assembly
- DisCatSharp.Common.dll
TimeSpanRegex()
[GeneratedRegex("^(?<days>\\d+d\\s*)?(?<hours>\\d{1,2}h\\s*)?(?<minutes>\\d{1,2}m\\s*)?(?<seconds>\\d{1,2}s\\s*)?$", RegexOptions.Compiled|RegexOptions.ECMAScript)]
public static Regex TimeSpanRegex()
Returns
Remarks
Pattern:
^(?<days>\\d+d\\s*)?(?<hours>\\d{1,2}h\\s*)?(?<minutes>\\d{1,2}m\\s*)?(?<seconds>\\d{1,2}s\\s*)?$Options:<br />
<pre><code class="lang-csharp">RegexOptions.Compiled | RegexOptions.ECMAScript</code></pre><br />
Explanation:<br />
<pre><code class="lang-csharp">○ Match if at the beginning of the string.
○ Optional (greedy). ○ "days" capture group. ○ Match a character in the set [0-9] atomically at least once. ○ Match 'd'. ○ Match a whitespace character (ECMA) greedily any number of times. ○ Optional (greedy). ○ "hours" capture group. ○ Match a character in the set [0-9] atomically at least 1 and at most 2 times. ○ Match 'h'. ○ Match a whitespace character (ECMA) greedily any number of times. ○ Optional (greedy). ○ "minutes" capture group. ○ Match a character in the set [0-9] atomically at least 1 and at most 2 times. ○ Match 'm'. ○ Match a whitespace character (ECMA) greedily any number of times. ○ Optional (greedy). ○ "seconds" capture group. ○ Match a character in the set [0-9] atomically at least 1 and at most 2 times. ○ Match 's'. ○ Match a whitespace character (ECMA) greedily any number of times. ○ Match if at the end of the string or if before an ending newline.