I'm using Total Commander (file manager), which allows searching file content by regular expressions.
I'd like to search PHP files for deprecated syntax like $_SESSION[user]
- so, I need the RegExp for finding all tags, which don't have quotes inside the square brackets.
Any ideas?
This is assuming you don't have defined constants:
\$\w+\[\s*(?:[a-zA-Z]+|[a-zA-Z]+(?:"|')|(?:"|')[a-zA-Z]+)\s*\]
Explanation:
\$
: match $
\w+
: match [a-zA-Z0-9_]
one or more times\[
: match [
\s*
: match white spaces zero or more times(?:[a-zA-Z]+|[a-zA-Z]+(?:"|')|(?:"|')[a-zA-Z]+)
: match "
or '
followed by letters, or just letters, or letters followed by '
or "
\s*
: match white spaces zero or more times\]
: match ]
Disclaimer: This will not validate your variables for example
$0[aaa]
would be matched.