Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
[^a-zA-Z0-9-]
/
g

Description

Make folder/url safe

use with eg sed:

echo 'My fancy $thing' | sed 's/[^a-zA-Z0-9-]/-/g'

results in My-fancy--thing

Submitted by anonymous - 2 years ago