summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibRegex/RegexByteCode.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibRegex/RegexByteCode.cpp b/Userland/Libraries/LibRegex/RegexByteCode.cpp
index 050f067ae0..e0e6cbe175 100644
--- a/Userland/Libraries/LibRegex/RegexByteCode.cpp
+++ b/Userland/Libraries/LibRegex/RegexByteCode.cpp
@@ -900,6 +900,21 @@ Vector<String> OpCode_Compare::variable_arguments_to_string(Optional<MatchInput>
} else if (compare_type == CharacterCompareType::Reference) {
auto ref = m_bytecode->at(offset++);
result.empend(String::formatted("number={}", ref));
+ if (input.has_value()) {
+ if (state().capture_group_matches.size() > input->match_index) {
+ auto& match = state().capture_group_matches[input->match_index];
+ if (match.size() > ref) {
+ auto& group = match[ref];
+ result.empend(String::formatted("left={}", group.left_column));
+ result.empend(String::formatted("right={}", group.left_column + group.view.length_in_code_units()));
+ result.empend(String::formatted("contents='{}'", group.view));
+ } else {
+ result.empend(String::formatted("(invalid ref, max={})", match.size() - 1));
+ }
+ } else {
+ result.empend(String::formatted("(invalid index {}, max={})", input->match_index, state().capture_group_matches.size() - 1));
+ }
+ }
} else if (compare_type == CharacterCompareType::String) {
auto& length = m_bytecode->at(offset++);
StringBuilder str_builder;