Community Patterns

Community Library Entry

0

Regular Expression
Created·2022-12-16 15:41
Updated·2023-01-02 12:23
Flavor·PCRE2 (PHP)

/
(<script\b[^><]*>)(.*?)(<\/script>)|\bon\w+\s*=\s*\K(?|(\")([^\"]+)\"|(')([^']+)')
/
isg
Open regex in editor

Description

Needed to find all content between <script>...</script> tags, plus any content within a < tag > that has an argument starting with on, e.g. <span onClick='abc'>

See https://onlinephp.io/ for PHP runtime

Submitted by anonymous