Last active
June 11, 2019 18:56
-
-
Save thbighead/8aa69170d538a4f8479e903f7659cea5 to your computer and use it in GitHub Desktop.
Regex to remove selected columns in a SQL query which have dynamic alias pointed by [anythinghere] flags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
preg_replace('/(SELECT\s*\S*\s+\[[^\[\]]*\]|([a-zA-Z]*\(.*)?,\s*\S*\s+\[[^\[\]]*\])/', '', $input_lines); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You just got to be careful with the remaining query, as it can remove the
SELECT
and keep a comma into it's very beginning