Regular Expressions 101

Community Patterns

1...56789...588

Replace function declaration with const arrow function

0

Regular Expression
PCRE2 (PHP >=7.3)

/
(async )?(function) ([a-zA-Z0-9]+)(\([^\)]*\))(\n)?
/
gm

Description

Captures a function declaration and changes it to an arrow function with const at the beginning.

Submitted by anonymous - 2 years ago (Last modified 2 years ago)