Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Darn you Microsoft!

Darn you Microsoft!

Scheduled Pinned Locked Moved The Weird and The Wonderful
regexcsharpvisual-studiocom
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #1

    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 a Regex object for the specified pattern and returns the result of Matches ( somestring ). I've been using this for a while now. Buuut... today I discovered that the MatchCollection and Match classes don't provide access to the Regex object that produced them! Which means I can't iterate the group names -- only the Regex class provides the GetGroupNames() method. (They both have private a field for the Regex.) Regex.GetGroupNames Method (System.Text.RegularExpressions)[^] So, when I need to iterate the group names, I can't use my Extension Method. :sigh:

    R R Richard DeemingR 3 Replies Last reply
    0
    • P PIEBALDconsult

      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 a Regex object for the specified pattern and returns the result of Matches ( somestring ). I've been using this for a while now. Buuut... today I discovered that the MatchCollection and Match classes don't provide access to the Regex object that produced them! Which means I can't iterate the group names -- only the Regex class provides the GetGroupNames() method. (They both have private a field for the Regex.) Regex.GetGroupNames Method (System.Text.RegularExpressions)[^] So, when I need to iterate the group names, I can't use my Extension Method. :sigh:

      R Offline
      R Offline
      RickZeeland
      wrote on last edited by
      #2

      You could download the .NET core source code and fix it :-\

      1 Reply Last reply
      0
      • P PIEBALDconsult

        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 a Regex object for the specified pattern and returns the result of Matches ( somestring ). I've been using this for a while now. Buuut... today I discovered that the MatchCollection and Match classes don't provide access to the Regex object that produced them! Which means I can't iterate the group names -- only the Regex class provides the GetGroupNames() method. (They both have private a field for the Regex.) Regex.GetGroupNames Method (System.Text.RegularExpressions)[^] So, when I need to iterate the group names, I can't use my Extension Method. :sigh:

        R Offline
        R Offline
        Ron Anders
        wrote on last edited by
        #3

        Yuma.... how cruel your judgments. :-D

        1 Reply Last reply
        0
        • P PIEBALDconsult

          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 a Regex object for the specified pattern and returns the result of Matches ( somestring ). I've been using this for a while now. Buuut... today I discovered that the MatchCollection and Match classes don't provide access to the Regex object that produced them! Which means I can't iterate the group names -- only the Regex class provides the GetGroupNames() method. (They both have private a field for the Regex.) Regex.GetGroupNames Method (System.Text.RegularExpressions)[^] So, when I need to iterate the group names, I can't use my Extension Method. :sigh:

          Richard DeemingR Offline
          Richard DeemingR Offline
          Richard Deeming
          wrote on last edited by
          #4

          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

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          P 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            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

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Version Information Available since 4.7 No use to me.

            Richard DeemingR 1 Reply Last reply
            0
            • P PIEBALDconsult

              Version Information Available since 4.7 No use to me.

              Richard DeemingR Offline
              Richard DeemingR Offline
              Richard Deeming
              wrote on last edited by
              #6

              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

              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

              P 1 Reply Last reply
              0
              • Richard DeemingR Richard Deeming

                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

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                Neither does SQL Server.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups