forked from y-scope/clp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f640e28
commit 876e9f9
Showing
10 changed files
with
173 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
set( | ||
REGEX_UTILS_HEADER_LIST | ||
"ErrorCode.hpp" | ||
"RegexToWildcardTranslatorConfig.hpp" | ||
"constants.hpp" | ||
"ErrorCode.hpp" | ||
"regex_translation_utils.hpp" | ||
"RegexToWildcardTranslatorConfig.hpp" | ||
) | ||
add_library( | ||
regex_utils | ||
regex_translation_utils.cpp | ||
ErrorCode.cpp | ||
regex_translation_utils.cpp | ||
${REGEX_UTILS_HEADER_LIST} | ||
) | ||
add_library(clp::regex_utils ALIAS regex_utils) | ||
target_include_directories(regex_utils | ||
PUBLIC | ||
../ | ||
PRIVATE | ||
../ | ||
"${PROJECT_SOURCE_DIR}/submodules" | ||
) | ||
target_compile_features(regex_utils PRIVATE cxx_std_20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Regex_utils | ||
|
||
This library contains useful utilities to handle all regex related tasks. | ||
|
||
## Regex to Wildcard Translator | ||
|
||
### Goal | ||
|
||
Performs a best-effort translation to turn a regex string to an equivalent wildcard string. | ||
|
||
CLP currently only recognizes three meta-characters in the wildcard syntax: | ||
|
||
* `?` Matches any single character | ||
* `*` Matches zero or more characters | ||
* `\` Suppresses the special meaning of meta characters (including itself) | ||
|
||
If the regex query can actually be expressed as a wildcard query only deploying the three | ||
metacharacters above, CLP should use the wildcard version. | ||
|
||
### Includes | ||
|
||
* To use the translator: | ||
|
||
```shell | ||
#include <regex_utils/regex_translation_utils.hpp> | ||
``` | ||
|
||
* To add custom configuration to the translator: | ||
|
||
```shell | ||
#include <regex_utils/RegexToWildcardTranslatorConfig.hpp> | ||
``` | ||
|
||
### Functionalities | ||
|
||
* Wildcards | ||
- Turn `.` into `?` | ||
- Turn `.*` into `*` | ||
- Turn `.+` into `?*` | ||
|
||
### Custom configuration | ||
|
||
* `add_prefix_suffix_wildcards`: in the absence of regex anchors, add prefix or suffix wildcards so | ||
the query becomes a substring query. | ||
- E.g. `info.*system` gets translated into `*info*system*` which makes the original query a | ||
substring query. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.