mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 19:05:08 +00:00
expr: Make Match expressions comply with POSIX
They should print the contents of capture group 1, if it exists.
This commit is contained in:
parent
11a8476cf4
commit
a5bc366d9a
1 changed files with 8 additions and 5 deletions
|
@ -359,7 +359,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool truth() const override { return integer() != 0; }
|
virtual bool truth() const override
|
||||||
|
{
|
||||||
|
if (type() == Expression::Type::String)
|
||||||
|
return !string().is_empty();
|
||||||
|
return integer() != 0;
|
||||||
|
}
|
||||||
virtual int integer() const override
|
virtual int integer() const override
|
||||||
{
|
{
|
||||||
if (m_op == StringOperation::Substring || m_op == StringOperation::Match) {
|
if (m_op == StringOperation::Substring || m_op == StringOperation::Match) {
|
||||||
|
@ -411,10 +416,8 @@ private:
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
StringBuilder result;
|
StringBuilder result;
|
||||||
for (auto& m : match.capture_group_matches) {
|
for (auto& e : match.capture_group_matches[0])
|
||||||
for (auto& e : m)
|
result.append(e.view.u8view());
|
||||||
result.append(e.view.to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.build();
|
return result.build();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue