Regular Expressions 101

Community Patterns

Variable name of code

5

Regular Expression
PCRE (PHP <7.3)

/
^(.*?([^\(=\s!<>]+?)\s*?=[^=<>].*;)(.*)$
/

Description

To get a variable name from a source code: The variable name is before the '=' (equal sign) This is the way to detect. Problem:

  1. Only 1 variable can get from 1 line.
  2. Unfortunately, this can get variable between after "//" and before ";" too.

I made this for fake script debugger. Just get variable from source code and put that after last semicolon with so much tab and messagebox code for every line.

Submitted by Setsuna - 9 years ago