Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
[^a-zA-Z_\x7f-\xff\d]
/
g

Description

This can be used in a preg_replace function to take any string value and strip all invalid characters to make a valid PHP variable

Submitted by Deathnerd - 9 years ago