Skip to content

Conversation

@badumbatish
Copy link

Hi there, i'm opening the PR to add a small regex engine to the Fex codebase. The motivation is to help dynamic modify some config option based on the name of the config file. Please see the following screenshot for more context.
Screenshot 2025-12-15 at 7 25 58 AM.

The regex engine is an NFA based one, implemented from the dragon book 2nd ed.

Implementation is in FEXCore/Source/Utils/Regex.cpp.
Test case is unittests/APITests/Regex.cpp.

I took the liberty to refactor and reuse a bit of the code in parsing the json. The traversing of a json list of pair of strings is now a helper function called ListApplier that accepts a json_t.

The default behavior is that the config loader goes through each regex and see if it matches the config name, if it does, it applies the config option specified and then stops checking anymore regex (this can change based on the need and reviews of the PR).

I'm not sure where should i add the test case for the new config loader. I tested locally via /home/ubuntu/.fex-emu/Config.json and it works, would love some suggestions

{
  "Config":
    {"RootFS":"Ubuntu_22_04"},
  "ThunksDB":{},
  "RegexConfig" : {
    ".*" : {
      "RootFS":"Ubuntu_24_04",
    }
  }
}

@badumbatish badumbatish changed the title Add Regex Engine to FEX Add Regex Engine to FEX for config option loading Dec 15, 2025
@bylaws
Copy link
Collaborator

bylaws commented Dec 15, 2025

I'm unsure on a full regex engine, I think a very naive glob impl might be enough. albeit this is very neat

@@ -0,0 +1,75 @@
#pragma once
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a concern about including this regex_engine that has no license. When it says "Inspiration taken from ..." and it's pretty much the code from https://github.com/0xsh4dy/regex_engine .
Attribution doesn't really matter when no license exists.

Copy link
Member

@Sonicadvance1 Sonicadvance1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the concern about the licensing of the regex engine used, I'm fine with this type of change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants