I've a text file containing large number of queries. I want to get all the distinct tables used in the entire file in all the queries. The table name can come after a 'from' or 'join'. How can i extract them by doing a regex match. Can anyone suggest a regular expression to get the matches?
You can use RegEx in many languages like PHP, Python, and also SQL. RegEx lets you match patterns by character class (like all letters, or just vowels, or all digits), between alternatives, and other really flexible options.
REGEXP is the operator used when performing regular expression pattern matches. RLIKE is the synonym. It also supports a number of metacharacters which allow more flexibility and control when performing pattern matching. The backslash is used as an escape character.
Regexp queryedit. Returns documents that contain terms matching a regular expression. A regular expression is a way to match patterns in data using placeholder characters, called operators. For a list of operators supported by the regexp query, see Regular expression syntax.
It depends on structure of your file. Try to use this:
(?<=from|join)(\s+\w+\b)
Also turn on options Multiline if your not split your file in array or smth else with singleline string members. Also try to turn on IgnorCase option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With