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. I think I just built a better mousetrap

I think I just built a better mousetrap

Scheduled Pinned Locked Moved The Weird and The Wonderful
regexalgorithmsdata-structures
1 Posts 1 Posters 3 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.
  • honey the codewitchH Offline
    honey the codewitchH Offline
    honey the codewitch
    wrote on last edited by
    #1

    1. ba((r|a|b|c)|z+)
    2. ba((r|(a|(b|c)))|z(z)*)
    3. ba([ra-c]|z+)

    There are 3 major algorithms for converting a state machine to a regular expression. Of these, the cleanest is probably the state-removal method, which I've employed. #1 is the original expression #2 is the expression recreated from a state machine using the state removal method #3 is the result of my new algorithm, based around the state removal method, but with improvements. Instead of building a string expression, I built out an abstract syntax tree for my regex After it is built, I can then do high level analysis and reduction on that expression tree. The result is #3. Woo! I went from not being able to solve this for years to improving on it pretty signficantly.

    Real programmers use butterflies

    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