0

I'm using the Hightlight Extension in VS Code that would markup parts of the code. I have sql models and what I want to do is to highlight when I have a combination at the join level. Eg:

Join table2 T1 ON t1.dbid = t2.dbid

so the pattern would be * join + word + ON + word.dbid = word.dbid

I've tried various combinations but nothing worked perfectly. Even tried a Regex generator.

(?i)^join [a-zA-Z]+ on +[a-zA-Z]+._db_id = [a-zA-Z]+._db_id$

Any ideas?

Álvaro González
147k45 gold badges282 silver badges378 bronze badges
asked Nov 24, 2022 at 11:13
1
  • Your expression doesn't account for table alias. Commented Nov 24, 2022 at 12:12

1 Answer 1

1

Try this one:

join\s+.*?\s+on\s+[^.]*?\.dbid\s*=\s*[^.]*?\.dbid

Important point: be sure you are not set as "Match case".

↓ tested here ↓

regex101

answered Nov 24, 2022 at 12:36
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.