Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
\G((?:.\D)*.)\d
/
g

Description

Replace every other character if it's a \d with * (only those in even positions: 2, 4, 6, etc).

Example: a1b2cde3~g45hi6 should become abcde~g4hi6

Submitted by anonymous - a month ago