Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save qwIvan/c23e1e84aed8b365ab13dfa054df106b to your computer and use it in GitHub Desktop.
Save qwIvan/c23e1e84aed8b365ab13dfa054df106b 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/74

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