Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save qwIvan/8ec83a3b0dc4f599b77eef4585d85451 to your computer and use it in GitHub Desktop.
Save qwIvan/8ec83a3b0dc4f599b77eef4585d85451 to your computer and use it in GitHub Desktop.

Revisions

  1. qwIvan created this gist Jan 15, 2019.
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    // https://regex101.com/r/yX5xS8/73

    const html = `
    <ImG
    sTyle=""
    src="http://t.cn/EqRt9Eh"
    class=">"
    Style=""
    />
    <ImG
    style=""
    src="http://t.cn/EqRt9Eh"
    class=">"
    STYLE=""
    >
    `.replace(/<((?:"[^"]*"['"]*|'[^']*'['"]*|[^'">\/])+)\/?>/gi, '<img style="max-width: 100%" $1 style="max-width: 100%" >');
    console.log(html)