Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@crisbeto
Copy link
Member

Updates the template syntax to support inline regular expressions. Also includes some logic to reuse regular expressions between call sites, unless they're marked as global.

Updates the expression lexer to produce tokens for regular expression literals.
Updates the template syntax to support inline regular expressions.
Adds the `RegularExpressionLiteral` node to the output AST.
…mpiler

Handles regular expression literals across the template type checker and the various translators.
Adds support for regular expression literals in the template pipeline and adds some logic to optimize non-global ones.
Updates the docs to mention that regular expressions are supported.
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release labels Sep 17, 2025
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: docs Related to the documentation area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime labels Sep 17, 2025
@ngbot ngbot bot added this to the Backlog milestone Sep 17, 2025
@crisbeto crisbeto requested a review from devversion September 17, 2025 08:52
@crisbeto crisbeto marked this pull request as ready for review September 17, 2025 08:52
@pullapprove pullapprove bot removed the request for review from devversion September 17, 2025 08:52
@crisbeto crisbeto requested a review from devversion September 17, 2025 09:13
Copy link
Member

@devversion devversion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

!lastToken.isString() &&
!lastToken.isKeyword() &&
!lastToken.isCharacter(chars.$RPAREN) &&
!lastToken.isCharacter(chars.$RBRACKET)
Copy link
Member

@devversion devversion Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what places is a regex starting? would it be less cases to catch where it can actually follow?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this logic, because the lexer works on a character-by-character basis. When we see a slash, we don't know if it'll be a regex or something like a / b.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I guess I was trying to ask if it would be simpler to inverse the checks here. E.g. check for left parenthesis— but I think it would likely be more verbose than this, so LGTM

}

override isConstant() {
return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this have an affect on the template pipeline? do you recall where this is used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly, we use it together with the constant pool to determine if a value can be extracted into a variable and reused. I'd consider regexes to be constant since they're immutable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I just wondered if the optimization logic with the g flag could be handled via isConstant here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried out removing the explicit optimization and relying on isConstant and the ConstantPool doing the right thing and it didn't work so things might've stopped working properly there at some point...

@crisbeto crisbeto added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 17, 2025
@crisbeto
Copy link
Member Author

Caretaker note: we may have to patch cl/808162868 into the sync CL.

thePunderWoman pushed a commit that referenced this pull request Sep 17, 2025
Updates the template syntax to support inline regular expressions.

PR Close #63857
thePunderWoman pushed a commit that referenced this pull request Sep 17, 2025
Adds the `RegularExpressionLiteral` node to the output AST.

PR Close #63857
thePunderWoman pushed a commit that referenced this pull request Sep 17, 2025
…mpiler (#63857)

Handles regular expression literals across the template type checker and the various translators.

PR Close #63857
thePunderWoman pushed a commit that referenced this pull request Sep 17, 2025
…ne (#63857)

Adds support for regular expression literals in the template pipeline and adds some logic to optimize non-global ones.

PR Close #63857
@thePunderWoman
Copy link
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

thePunderWoman pushed a commit that referenced this pull request Sep 17, 2025
Updates the docs to mention that regular expressions are supported.

PR Close #63857
AndrewKushnir added a commit to AndrewKushnir/angular that referenced this pull request Sep 17, 2025
AndrewKushnir added a commit to AndrewKushnir/angular that referenced this pull request Sep 17, 2025
AndrewKushnir added a commit to AndrewKushnir/angular that referenced this pull request Sep 17, 2025
AndrewKushnir added a commit to AndrewKushnir/angular that referenced this pull request Sep 17, 2025
AndrewKushnir added a commit to AndrewKushnir/angular that referenced this pull request Sep 17, 2025
AndrewKushnir added a commit to AndrewKushnir/angular that referenced this pull request Sep 17, 2025
thePunderWoman pushed a commit that referenced this pull request Sep 17, 2025
thePunderWoman pushed a commit that referenced this pull request Sep 17, 2025
thePunderWoman pushed a commit that referenced this pull request Sep 17, 2025
thePunderWoman pushed a commit that referenced this pull request Sep 17, 2025
thePunderWoman pushed a commit that referenced this pull request Sep 17, 2025
thePunderWoman pushed a commit that referenced this pull request Sep 17, 2025
wildcardalice pushed a commit to wildcardalice/angular that referenced this pull request Sep 18, 2025
Updates the expression lexer to produce tokens for regular expression literals.

PR Close angular#63857
wildcardalice pushed a commit to wildcardalice/angular that referenced this pull request Sep 18, 2025
Updates the template syntax to support inline regular expressions.

PR Close angular#63857
wildcardalice pushed a commit to wildcardalice/angular that referenced this pull request Sep 18, 2025
…lar#63857)

Adds the `RegularExpressionLiteral` node to the output AST.

PR Close angular#63857
wildcardalice pushed a commit to wildcardalice/angular that referenced this pull request Sep 18, 2025
…mpiler (angular#63857)

Handles regular expression literals across the template type checker and the various translators.

PR Close angular#63857
wildcardalice pushed a commit to wildcardalice/angular that referenced this pull request Sep 18, 2025
…ne (angular#63857)

Adds support for regular expression literals in the template pipeline and adds some logic to optimize non-global ones.

PR Close angular#63857
wildcardalice pushed a commit to wildcardalice/angular that referenced this pull request Sep 18, 2025
…#63857)

Updates the docs to mention that regular expressions are supported.

PR Close angular#63857
wildcardalice pushed a commit to wildcardalice/angular that referenced this pull request Sep 18, 2025
wildcardalice pushed a commit to wildcardalice/angular that referenced this pull request Sep 18, 2025
wildcardalice pushed a commit to wildcardalice/angular that referenced this pull request Sep 18, 2025
wildcardalice pushed a commit to wildcardalice/angular that referenced this pull request Sep 18, 2025
wildcardalice pushed a commit to wildcardalice/angular that referenced this pull request Sep 18, 2025
wildcardalice pushed a commit to wildcardalice/angular that referenced this pull request Sep 18, 2025
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: compiler Issues related to `ngc`, Angular's template compiler area: core Issues related to the framework runtime area: docs Related to the documentation detected: feature PR contains a feature commit merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.