How to take the content of the JOIN clause condition

Asked

Viewed 98 times

0

I have the following situation that can be seen in this link.

The expression is:

/((^|\s)(right|inner|left)\sjoin\s(.*?)on\s(.*?)(?=(inner|right|where)?))+/gmi

I need to get the conditions inside the on, plus other information that is already being captured.

Someone has a tip?

  • 1

    Can you describe better what the goal is? Are you trying to process SQL code? Perhaps it is better to look for a parser ready than to use regex, they will not be 100%.

  • I need to create a parser, because the ready ones do not fit so much to what I need, but the purpose of this question is that I need to take the amount of conditions and then separate each condition, if I have more than one.

1 answer

1

I do not know the origin of its expression (and even less if the result obtained was really the intended one) but I adapted it to achieve the values preceded by on.

So try with that one expression:

^(?<expressaocompleta>(?:^|\s)(?<tipojoin>right|inner|left)\sjoin\s(?<tabelasjoin>.*)\son\s(?<clausulas>.*(?<fatorcondicional>inner|right|where(?<condicao>.*))?))$

It’s a little big, but I mentioned it to make it a little more intuitive

Browser other questions tagged

You are not signed in. Login or sign up in order to post.