Regular Expressions 101

Community Patterns

Get table name from query

1

Regular Expression
PCRE (PHP <7.3)

/
(?:(?:from|join)(?:\s|\()+((?:\w*\.\w*)+)(?:\s|\))+)
/
gi

Description

this extracts the table name in the from or join clause from SQL query

Submitted by vwei02 - 8 years ago