Darn you Microsoft!
-
Darn you to Yuma! I have been doing some work with Extension Methods for Regular Expressions in .net this week. One in particular can be used like this:
MatchCollection m = somestring.Matches ( somepattern ) ;
This works fine. The method instantiates aRegex
object for the specified pattern and returns the result ofMatches ( somestring )
. I've been using this for a while now. Buuut... today I discovered that theMatchCollection
andMatch
classes don't provide access to theRegex
object that produced them! Which means I can't iterate the group names -- only theRegex
class provides theGetGroupNames()
method. (They both have private a field for theRegex
.) Regex.GetGroupNames Method (System.Text.RegularExpressions)[^] So, when I need to iterate the group names, I can't use my Extension Method. :sigh: -
Darn you to Yuma! I have been doing some work with Extension Methods for Regular Expressions in .net this week. One in particular can be used like this:
MatchCollection m = somestring.Matches ( somepattern ) ;
This works fine. The method instantiates aRegex
object for the specified pattern and returns the result ofMatches ( somestring )
. I've been using this for a while now. Buuut... today I discovered that theMatchCollection
andMatch
classes don't provide access to theRegex
object that produced them! Which means I can't iterate the group names -- only theRegex
class provides theGetGroupNames()
method. (They both have private a field for theRegex
.) Regex.GetGroupNames Method (System.Text.RegularExpressions)[^] So, when I need to iterate the group names, I can't use my Extension Method. :sigh:You could download the .NET core source code and fix it :-\
-
Darn you to Yuma! I have been doing some work with Extension Methods for Regular Expressions in .net this week. One in particular can be used like this:
MatchCollection m = somestring.Matches ( somepattern ) ;
This works fine. The method instantiates aRegex
object for the specified pattern and returns the result ofMatches ( somestring )
. I've been using this for a while now. Buuut... today I discovered that theMatchCollection
andMatch
classes don't provide access to theRegex
object that produced them! Which means I can't iterate the group names -- only theRegex
class provides theGetGroupNames()
method. (They both have private a field for theRegex
.) Regex.GetGroupNames Method (System.Text.RegularExpressions)[^] So, when I need to iterate the group names, I can't use my Extension Method. :sigh:Yuma.... how cruel your judgments. :-D
-
Darn you to Yuma! I have been doing some work with Extension Methods for Regular Expressions in .net this week. One in particular can be used like this:
MatchCollection m = somestring.Matches ( somepattern ) ;
This works fine. The method instantiates aRegex
object for the specified pattern and returns the result ofMatches ( somestring )
. I've been using this for a while now. Buuut... today I discovered that theMatchCollection
andMatch
classes don't provide access to theRegex
object that produced them! Which means I can't iterate the group names -- only theRegex
class provides theGetGroupNames()
method. (They both have private a field for theRegex
.) Regex.GetGroupNames Method (System.Text.RegularExpressions)[^] So, when I need to iterate the group names, I can't use my Extension Method. :sigh:PIEBALDconsult wrote:
So, when I need to iterate the group names, I can't use my Extension Method.
Why not?
Match theMatch = ...;
foreach (Group g in theMatch.Groups)
{
Console.WriteLine($"{g.Name}: {g.Value}");
}Match.Groups property[^] Group.Name property[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
PIEBALDconsult wrote:
So, when I need to iterate the group names, I can't use my Extension Method.
Why not?
Match theMatch = ...;
foreach (Group g in theMatch.Groups)
{
Console.WriteLine($"{g.Name}: {g.Value}");
}Match.Groups property[^] Group.Name property[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Version Information Available since 4.7 No use to me.
-
Version Information Available since 4.7 No use to me.
What, you mean you don't upgrade to the latest version the second it's released? :rolleyes:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
What, you mean you don't upgrade to the latest version the second it's released? :rolleyes:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Neither does SQL Server.