Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
^\s*(public|protected|private){1}\s*\$([a-zA-Z0-9_]+)\s*;\s*$
/
mg

Description

I use this regex to quickly convert the class' variables into a string which is usable with the "function" array. I copy-paste the varialbe name and use this regex. Useful to convert all your variable and put it in the magic function __sleep(). After it, you can delete the variables you don't want.

Submitted by anonymous - 10 years ago