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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. If you think regex is already difficult...

If you think regex is already difficult...

Scheduled Pinned Locked Moved The Lounge
3 Posts 2 Posters 477 Views
  • 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.
  • code-witchC Offline
    code-witchC Offline
    code-witch
    wrote on last edited by
    #1

    ...you won't like the following problem.

    The object: Eliminating lazy matches from a regular expression by replacing them with the equivalent greedy expression:
    C block comment:
    lazy:

    /\*(.|\n)*?\*/
    

    vs greedy equivalent:

    /\*([^\*]|\*+[^*/])*\*+/
    

    lazy:

    f(u|o)*?bar
    

    vs greedy equivalent:

    f([^uob]|(u|o)+[^b]|(u|o)*b[^a]|(u|o)*ba[^r])*bar
    

    The thing that will cost me sleep is I can almost see the pattern enough to implement it. Almost doesn't really count though, and that's the frustrating part. May as well be the moon.

    169af173-2737-4203-83e0-28d50f803791-image.png

    1 Reply Last reply
    0
    • Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      Here's the way I read regex expressions:

      }{$*(**#&^$%@

      code-witchC 1 Reply Last reply
      1
      • Richard Andrew x64R Richard Andrew x64

        Here's the way I read regex expressions:

        }{$*(**#&^$%@

        code-witchC Offline
        code-witchC Offline
        code-witch
        wrote on last edited by
        #3

        @Richard-Andrew-x64 accurate

        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