Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Created·2024-10-08 16:11
Flavor·PCRE2 (PHP)

/
\G((?:.\D)*.)\d
/
g
Open regex in editor

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