mirror of https://github.com/WerWolv/ImHex.git
feat: Added "Require full match" toggle to regex string search
This commit is contained in:
parent
8c219b981c
commit
9d7e2eccac
|
@ -61,6 +61,7 @@ namespace hex::plugin::builtin {
|
|||
|
||||
struct Regex {
|
||||
std::string pattern;
|
||||
bool fullMatch = true;
|
||||
} regex;
|
||||
|
||||
struct BinaryPattern {
|
||||
|
|
|
@ -271,8 +271,13 @@ namespace hex::plugin::builtin {
|
|||
std::string string(occurrence.region.getSize(), '\x00');
|
||||
provider->read(occurrence.region.getStartAddress(), string.data(), occurrence.region.getSize());
|
||||
|
||||
if (std::regex_match(string, regex))
|
||||
result.push_back(occurrence);
|
||||
if (settings.fullMatch) {
|
||||
if (std::regex_match(string, regex))
|
||||
result.push_back(occurrence);
|
||||
} else {
|
||||
if (std::regex_search(string, regex))
|
||||
result.push_back(occurrence);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -473,7 +478,7 @@ namespace hex::plugin::builtin {
|
|||
|
||||
mode = SearchSettings::Mode::Regex;
|
||||
|
||||
ImGui::InputText("hex.builtin.view.find.regex"_lang, settings.pattern);
|
||||
ImGui::InputText("hex.builtin.view.find.regex.pattern"_lang, settings.pattern);
|
||||
|
||||
try {
|
||||
std::regex regex(settings.pattern);
|
||||
|
@ -485,6 +490,8 @@ namespace hex::plugin::builtin {
|
|||
if (settings.pattern.empty())
|
||||
this->m_settingsValid = false;
|
||||
|
||||
ImGui::Checkbox("hex.builtin.view.find.regex.full_match"_lang, &settings.fullMatch);
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("hex.builtin.view.find.binary_pattern"_lang)) {
|
||||
|
|
|
@ -414,6 +414,8 @@ namespace hex::plugin::builtin {
|
|||
{ "hex.builtin.view.find.strings.line_feeds", "Line Feeds" },
|
||||
{ "hex.builtin.view.find.sequences", "Sequenzen" },
|
||||
{ "hex.builtin.view.find.regex", "Regex" },
|
||||
{ "hex.builtin.view.find.regex.pattern", "Pattern" },
|
||||
{ "hex.builtin.view.find.regex.full_match", "Benötige volle übereinstimmung" },
|
||||
{ "hex.builtin.view.find.binary_pattern", "Binärpattern" },
|
||||
{ "hex.builtin.view.find.search", "Suchen" },
|
||||
{ "hex.builtin.view.find.context.copy", "Wert Kopieren" },
|
||||
|
|
|
@ -420,6 +420,8 @@ namespace hex::plugin::builtin {
|
|||
{ "hex.builtin.view.find.strings.line_feeds", "Line Feeds" },
|
||||
{ "hex.builtin.view.find.sequences", "Sequences" },
|
||||
{ "hex.builtin.view.find.regex", "Regex" },
|
||||
{ "hex.builtin.view.find.regex.pattern", "Pattern" },
|
||||
{ "hex.builtin.view.find.regex.full_match", "Require full match" },
|
||||
{ "hex.builtin.view.find.binary_pattern", "Binary Pattern" },
|
||||
{ "hex.builtin.view.find.search", "Search" },
|
||||
{ "hex.builtin.view.find.context.copy", "Copy Value" },
|
||||
|
|
|
@ -419,6 +419,8 @@ namespace hex::plugin::builtin {
|
|||
// { "hex.builtin.view.find.strings.line_feeds", "Line Feeds" },
|
||||
// { "hex.builtin.view.find.sequences", "Sequences" },
|
||||
// { "hex.builtin.view.find.regex", "Regex" },
|
||||
//{ "hex.builtin.view.find.regex.pattern", "Pattern" },
|
||||
//{ "hex.builtin.view.find.regex.full_match", "Require full match" },
|
||||
// { "hex.builtin.view.find.binary_pattern", "Binary Pattern" },
|
||||
// { "hex.builtin.view.find.search", "Search" },
|
||||
// { "hex.builtin.view.find.context.copy", "Copy Value" },
|
||||
|
|
|
@ -422,6 +422,8 @@ namespace hex::plugin::builtin {
|
|||
{ "hex.builtin.view.find.strings.line_feeds", "ラインフィード" },
|
||||
{ "hex.builtin.view.find.sequences", "通常検索" },
|
||||
{ "hex.builtin.view.find.regex", "正規表現" },
|
||||
// { "hex.builtin.view.find.regex.pattern", "Pattern" },
|
||||
// { "hex.builtin.view.find.regex.full_match", "Require full match" },
|
||||
{ "hex.builtin.view.find.binary_pattern", "16進数" },
|
||||
{ "hex.builtin.view.find.search", "検索を実行" },
|
||||
{ "hex.builtin.view.find.context.copy", "値をコピー" },
|
||||
|
|
|
@ -419,6 +419,8 @@ namespace hex::plugin::builtin {
|
|||
{ "hex.builtin.view.find.strings.line_feeds", "라인 피드" },
|
||||
{ "hex.builtin.view.find.sequences", "텍스트 시퀸스" },
|
||||
{ "hex.builtin.view.find.regex", "정규식" },
|
||||
// { "hex.builtin.view.find.regex.pattern", "Pattern" },
|
||||
// { "hex.builtin.view.find.regex.full_match", "Require full match" },
|
||||
{ "hex.builtin.view.find.binary_pattern", "바이너리 패턴" },
|
||||
{ "hex.builtin.view.find.search", "검색" },
|
||||
{ "hex.builtin.view.find.context.copy", "값 복사" },
|
||||
|
|
|
@ -417,6 +417,8 @@ namespace hex::plugin::builtin {
|
|||
// { "hex.builtin.view.find.strings.line_feeds", "Line Feeds" },
|
||||
// { "hex.builtin.view.find.sequences", "Sequences" },
|
||||
// { "hex.builtin.view.find.regex", "Regex" },
|
||||
// { "hex.builtin.view.find.regex.pattern", "Pattern" },
|
||||
// { "hex.builtin.view.find.regex.full_match", "Require full match" },
|
||||
// { "hex.builtin.view.find.binary_pattern", "Binary Pattern" },
|
||||
// { "hex.builtin.view.find.search", "Search" },
|
||||
// { "hex.builtin.view.find.context.copy", "Copy Value" },
|
||||
|
|
|
@ -420,6 +420,8 @@ namespace hex::plugin::builtin {
|
|||
{ "hex.builtin.view.find.strings.line_feeds", "换行" },
|
||||
{ "hex.builtin.view.find.sequences", "序列" },
|
||||
{ "hex.builtin.view.find.regex", "正则表达式" },
|
||||
// { "hex.builtin.view.find.regex.pattern", "Pattern" },
|
||||
// { "hex.builtin.view.find.regex.full_match", "Require full match" },
|
||||
{ "hex.builtin.view.find.binary_pattern", "二进制模式" },
|
||||
{ "hex.builtin.view.find.search", "搜索" },
|
||||
{ "hex.builtin.view.find.context.copy", "复制值" },
|
||||
|
|
|
@ -418,6 +418,8 @@ namespace hex::plugin::builtin {
|
|||
// { "hex.builtin.view.find.strings.line_feeds", "Line Feeds" },
|
||||
// { "hex.builtin.view.find.sequences", "Sequences" },
|
||||
// { "hex.builtin.view.find.regex", "Regex" },
|
||||
// { "hex.builtin.view.find.regex.pattern", "Pattern" },
|
||||
// { "hex.builtin.view.find.regex.full_match", "Require full match" },
|
||||
// { "hex.builtin.view.find.binary_pattern", "Binary Pattern" },
|
||||
// { "hex.builtin.view.find.search", "Search" },
|
||||
// { "hex.builtin.view.find.context.copy", "Copy Value" },
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue