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. General Programming
  3. C#
  4. Is there something faster than .|[\r\n] in RegExp ?

Is there something faster than .|[\r\n] in RegExp ?

Scheduled Pinned Locked Moved C#
question
6 Posts 3 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.
  • E Offline
    E Offline
    ektoras
    wrote on last edited by
    #1

    Is there something faster than .|[\r\n] in Regular Expressions ?

    D L 2 Replies Last reply
    0
    • E ektoras

      Is there something faster than .|[\r\n] in Regular Expressions ?

      D Offline
      D Offline
      DavidNohejl
      wrote on last edited by
      #2

      Like to pass RegexOptions.SingleLine[^] into Regex costructor[^]? I don't know if it is faster but I'd give it a try (If I understand your regex correctly, it's pretty simple but these are strange days for me...). David Never forget: "Stay kul and happy" (I.A.)
      David's thoughts / dnhsoftware.org / MyHTMLTidy

      1 Reply Last reply
      0
      • E ektoras

        Is there something faster than .|[\r\n] in Regular Expressions ?

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        That will just match the first char of the string. So I guess you can just use string[0]. xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

        E 1 Reply Last reply
        0
        • L leppie

          That will just match the first char of the string. So I guess you can just use string[0]. xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

          E Offline
          E Offline
          ektoras
          wrote on last edited by
          #4

          I want to match multiple-line comments from /* to */ so I use: Regex regex = new Regex("/\\*(**.|[\r\n]**)*?\\*/");

          L 1 Reply Last reply
          0
          • E ektoras

            I want to match multiple-line comments from /* to */ so I use: Regex regex = new Regex("/\\*(**.|[\r\n]**)*?\\*/");

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #5

            ektoras wrote: Regex regex = new Regex("/\\*(.|[\r\n])*?\\*/"); This could be slightly faster. You have a few unnessary constructs. Regex regex = new Regex("/\\*[.\r\n]*?\\*/"); xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

            E 1 Reply Last reply
            0
            • L leppie

              ektoras wrote: Regex regex = new Regex("/\\*(.|[\r\n])*?\\*/"); This could be slightly faster. You have a few unnessary constructs. Regex regex = new Regex("/\\*[.\r\n]*?\\*/"); xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

              E Offline
              E Offline
              ektoras
              wrote on last edited by
              #6

              It doesn't work.

              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