Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

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

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 - 2 years ago (Last modified 2 years ago)