Something wrong with regex? #284
-
Im using this rule to disable url paths without trailing slash (in django) id: test
message: test
severity: error
language: Python
rule:
regex: ^.+[^/]$
kind: string
not:
kind: keyword_argument
inside:
kind: argument_list
inside:
pattern: path($$$) but sg returns empty strings or strings with trailing slash. What am I missing? |
Beta Was this translation helpful? Give feedback.
Answered by
HerringtonDarkholme
Mar 9, 2023
Replies: 1 comment 7 replies
-
Regex is written in rust's syntax. https://docs.rs/regex/latest/regex/ |
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
q0w
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Regex is written in rust's syntax. https://docs.rs/regex/latest/regex/
Also, yaml has special string symbols. So don't forget to quote regex.
You can also use playground to debug it.
https://ast-grep.github.io/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InB5dGhvbiIsInF1ZXJ5IjoiY29uc29sZS5sb2coJE1BVENIKSIsImNvbmZpZyI6ImlkOiB0ZXN0XG5tZXNzYWdlOiB0ZXN0XG5zZXZlcml0eTogZXJyb3Jcbmxhbmd1YWdlOiBQeXRob25cbnJ1bGU6XG4gIHJlZ2V4OiAnXCIuK1teL11cIidcbiAga2luZDogc3RyaW5nXG4gIG5vdDpcbiAgICBraW5kOiBrZXl3b3JkX2FyZ3VtZW50XG4gIGluc2lkZTpcbiAgICBraW5kOiBhcmd1bWVudF9saXN0XG4gICAgaW5zaWRlOlxuICAgICAgcGF0dGVybjogcGF0aCgkJCQpIiwic291cmNlIjoicGF0aCgxMjMpXG5wYXRoKFwic2Rmd2V3ZVwiKSJ9