0

I am struggling to interpret the regex (?i)(^|[[^\\p{L}]&&\\D])(todo)($|[[^\\p{L}]&&\\D]) as used here: https://github.com/SonarSource/slang/blob/3a1b628419134646a7fcc15e93203c6ff8cc22fc/slang-checks/src/main/java/org/sonarsource/slang/checks/TodoCommentCheck.java#L37

What will it match? I understand the part about ignoring case. The part that i don't understand is [[^\\p{L}]&&\\D] - is it really matching the p, {, L characters in a character set ?

AnkurVj
  • 7,258
  • 9
  • 40
  • 52
  • Maybe [regex101](https://regex101.com/r/CNiUUD/2/) can help. – Turing85 Sep 27 '19 at 19:21
  • I have tried this, and other similar tools which do not seem to be interpreting it correctly. The sonarsource check is expected to match any statements with a TODO, such as `// TODO (avj) [JIRA-12345]: Add unit tests`, but regex 101 doesn't seem to be agreeing – AnkurVj Sep 27 '19 at 19:24
  • "*The sonarsource check is expected to....*" - It clearly does not. First, you use `&` instead of `&&` in capturing groups for logical groups. Second, within `[` and `]`, everything is evaluated as-is, so `[[]` matches `[`. Third, you are missing some `*`. Fourth, in the 3rd capturing group (the part after `todo`), the regex denies numbers, but in your sample, you have a number on the right of `TODO`. – Turing85 Sep 27 '19 at 19:42

0 Answers0