Matching Multiple Loop Variables #717
-
I would like to match loop iterators in into separate meta variables. For example, in the below code, I would like to match both 'i' and 'j' into separate meta variables.
Here is my unsuccessful attempt in the playground. Thanks in advance for your help! Edit: Seems like the pattern syntax works but the template syntax doesn't? |
Beta Was this translation helpful? Give feedback.
Answered by
HerringtonDarkholme
Nov 16, 2023
Replies: 2 comments 3 replies
-
I'm not too sure about your question but looks like this can work? In YAML rule, |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks! Is there a way I could use this kind of syntax? I'm looking to build a more complex rule on top of this |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://ast-grep.github.io/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InB5dGhvbiIsInF1ZXJ5IjoiICAgICAgICAgIHByaW50KCRJKyRKKSIsInJld3JpdGUiOiIiLCJjb25maWciOiJydWxlOlxuICBraW5kOiBmb3Jfc3RhdGVtZW50XG4gIGFsbDpcbiAgICAtIGhhczpcbiAgICAgICAgZmllbGQ6IGxlZnRcbiAgICAgICAgcGF0dGVybjogXG4gICAgICAgICAgY29udGV4dDogJ2ZvciAkSSwkSiBpbiBbXTogJCQkJ1xuICAgICAgICAgIHNlbGVjdG9yOiBwYXR0ZXJuX2xpc3RcbiAgICAtIGhhczpcbiAgICAgICAgZmllbGQ6IGJvZHlcbiAgICAgICAgaGFzOlxuICAgICAgICAgIHBhdHRlcm46IHByaW50KCRJKyRKKVxuICAgICAgICAgIHN0b3BCeTogZW5kIiwic291cmNlIjoiZm9yIGksaiBpbiBhcnI6XG4gICAgcHJpbnQoaStqKSJ9
this should work