phpregexsearchtotal-commander

Searching by RegExp (Total Commander / PHP)


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?


Solution

  • This is assuming you don't have defined constants:
    \$\w+\[\s*(?:[a-zA-Z]+|[a-zA-Z]+(?:"|')|(?:"|')[a-zA-Z]+)\s*\]

    Explanation:

    Online demo

    Disclaimer: This will not validate your variables for example $0[aaa] would be matched.