Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplification
  • Loading branch information
lemire authored and anonrig committed Jan 22, 2025
commit 42688f6197b4197a1545cdc4f07e929962328c87
4 changes: 2 additions & 2 deletions include/ada/url_pattern_regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ concept regex_concept = requires(T t, std::string_view pattern,
// Function to perform regex search
{
t.regex_search(input, std::declval<typename T::regex_type&>())
} -> std::same_as<std::optional<std::vector<std::string>>>;
} -> std::same_as<std::vector<std::string>>;

// Function to match regex pattern
{
Expand All @@ -44,7 +44,7 @@ class std_regex_provider {
using regex_type = std::regex;
static std::optional<regex_type> create_instance(std::string_view pattern,
bool ignore_case);
std::optional<std::vector<std::string>> regex_search(
std::vector<std::string> regex_search(
std::string_view input, const regex_type& pattern);
bool regex_match(std::string_view input, const regex_type& pattern);
};
Expand Down
15 changes: 11 additions & 4 deletions src/url_pattern_regex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ std::optional<std::regex> std_regex_provider::create_instance(
}
}

std::optional<std::vector<std::string>> std_regex_provider::regex_search(
std::vector<std::string> std_regex_provider::regex_search(
std::string_view input, const std::regex& pattern) {
(void)input;
(void)pattern;
return {};

std::vector<std::string> matches;
std::string input_str(input.begin(), input.end()); // Convert string_view to string for regex_search
std::smatch match_result;

while (std::regex_search(input_str, match_result, pattern)) {
matches.push_back(match_result.str());
input_str = match_result.suffix().str();
}
return matches;
}

bool std_regex_provider::regex_match(std::string_view input,
Expand Down