Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandanote-info/481e8fb47e45a04e519ef19128f22d22 to your computer and use it in GitHub Desktop.
Save pandanote-info/481e8fb47e45a04e519ef19128f22d22 to your computer and use it in GitHub Desktop.
WordPressに記事として書かれている文章のうち、設定ファイル、プログラム例及びコマンドの出力結果などを除いた部分のおおよその総文字数を求めるSQL文
-- WordPressに記事として書かれている文章のうち、
-- 設定ファイル、プログラム例及びコマンドの出力結果などを除いた部分のおおよその総文字数を求めるSQL文
-- なお、本SQL文を利用することにより得られた結果については責任は負いかねます。
select sum(char_length(regexp_replace(regexp_replace(regexp_replace(regexp_replace(post_content,'(?s)<div class="code">((?!</div>).)*?</div>',''),'<.+?>',''),'&.+?;','_'),'(\s+|\r\n|\n)','')))
as total from wp_posts where post_status = 'publish' and post_type = 'post';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment