Skip to content

Commit 2b297a0

Browse files
committed
Feat: GroupExtensions for Regex
**Twitch Redeems** - brought to you by `fluffycat_1337` - brought to you by `jeroenvanwissen` with : "I forgot what I wanted to put here"
1 parent b67260b commit 2b297a0

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=regex/@EntryIndexedValue">True</s:Boolean>
3+
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=regularexpressions/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// ---------------------------------------------------------------------------------------------------------------------
2+
// Imports
3+
// ---------------------------------------------------------------------------------------------------------------------
4+
using System.Diagnostics.CodeAnalysis;
5+
6+
// ReSharper disable once CheckNamespace
7+
namespace System.Text.RegularExpressions;
8+
9+
// ---------------------------------------------------------------------------------------------------------------------
10+
// Code
11+
// ---------------------------------------------------------------------------------------------------------------------
12+
public static class GroupExtensions {
13+
public static bool TryGetValue(this Group group,[NotNullWhen(true)] out string? value) {
14+
if (group.Success) {
15+
value = group.Value;
16+
return true;
17+
}
18+
value = null;
19+
return false;
20+
}
21+
22+
public static bool TryGetValueSpan(this Group group, out ReadOnlySpan<char> value) {
23+
if (group.Success) {
24+
value = group.ValueSpan;
25+
return true;
26+
}
27+
value = default;
28+
return false;
29+
}
30+
}

0 commit comments

Comments
 (0)