MT Regex - ikoaoki/mt-migration GitHub Wiki

MT Regex Plugin

正規表現が使えるようになるプラグイン。

MTクラウドでは動作しない。

特定の単語を違うものに変換する

<MTRegexDefine name="toph">s|トフ|<img src="/icon/toph.gif">|g</MTRegexDefine>
<MTEntries>
 <MTEntryBody regex="toph">
</MTEntries>

MT6に書き換え

特定の箇所だけ
<MTEntryBody regex_replace="/トフ/g","<img src="/icon/toph.png">">
全体に
<MTUnless regex_replace="/トフ/g","<img src="/icon/toph.png">">

<MTEntries>
 <MTEntryTitle>
 <MTEntryBody>
</MTEntries>

</MTUnless>

複数の条件をまとめて充てる

<MTRegexDefine name="pattern1">s|トフ|<strong>トフは可愛い</strong>|g</MTRegexDefine>
<MTRegexDefine name="pattern2">s|\[google\]|<a href="http://www.google.co.jp/">[Google]</a>|g</MTRegexDefine>

<MTEntries regex="pattern1 pattern2">
 <MTEntryTitle>
 <MTEntryBody>
</MTEntries>

MT6に書き換え

<MTUnless
 regex_replace="/トフ/g","<strong>トフは可愛い</strong>"
 regex_replace="/google/g","<a href="http://www.google.co.jp/">[Google]</a>"
>

<MTEntries>
 <MTEntryTitle>
 <MTEntryBody>
</MTEntries>

</MTUnless>

特定の単語を含む時に表示

 <MTEntries>
 <MTIfMatches pattern="m/インコ/">
  <MTEntryBody>
  </MTIfMatches>
 </MTEntries>

<MTRegexDefine name="match1">m/インコ/</MTRegexDefine>
<MTEntries>
 <MTIfMatches pattern="match1">
  <MTEntryBody>
 </MTIfMatches>
</MTEntries>

MT6に書き換え

MTIf のみで
<MTEntries>
 <MTIf tag="EntryBody" like="インコ">
  <MTEntryBody>
 </MTIf>
</MTEntries>
MTSetVarBlock と MTIf で
<MTEntries>
 <MTSetVarBlock name="match1"><MTEntryBody></MTSetVarBlock>
 <MTIf name="match1" like="インコ">
  <MTEntryBody>
 </MTIf>
</MTEntries>

特定の投稿者の記事のみを表示

一人の投稿者のみ

 <MTEntries>
  <MTIfMatches var="EntryAuthor" pattern="m/bird/">
   <MTEntryTitle>
  </MTIfMatches>
 </MTEntries>

複数の投稿者

<MTEntries>
 <MTIfNotMatches var="EntryAuthor" pattern="m/(dog|cat)/i">
   <MTEntryTitle>
 </MTIfNotMatches>
</MTEntries>

MT6に書き換え

一人の投稿者のみ

  <MTEntries author="bird">
   <MTEntryTitle>
  </MTEntries>

複数の投稿者

<MTEntries>
 <MTIf tag="EntryAuthor" like="^(dog|cat)">
  <MTEntryTitle>
 </MTIf>
</MTEntries>

特定の投稿者の記事のみを表示したくない

一人の投稿者のみ

<MTEntries>
 <MTIfNotMatches var="EntryAuthor" pattern="m/bird/">
  <MTEntryTitle>
  </MTIfNotMatches>
 </MTEntries>

複数の投稿者

<MTEntries>
 <MTIfNotMatches var="EntryAuthor" pattern="m/(dog|cat)/i">
  <MTEntryTitle>
 </MTIfNotMatches>
</MTEntries>

MT6に書き換え

一人の投稿者のみ

<MTEntries>
 <MTUnless tag="EntryAuthor" eq="bird">
  <MTEntryTitle>
 </MTUnless>
</MTEntries>

複数の投稿者

<MTEntries>
 <MTUnless tag="EntryAuthor" like="^(dog|cat)">
  <MTEntryTitle>
 </MTUnless>
</MTEntries>

記事100件目の時にだけ表示する

<MTIfMatches var="BlogEntryCount" value="100">
 当ブログは100記事を達成しました!
</MTIfMatches>

MT6に書き換え

記事100達成時のみ

<MTIf tag="BlogEntryCount" eq="100">
 当ブログは100記事を達成しました!
</MTIf>

記事100達成時以外でも表示する

<MTIf tag="BlogEntryCount" ge="100">
 当ブログは100記事を達成しました!
<MTElse>
 当ブログは100記事をまだ達成できてません…
</MTIf>

⚠️ **GitHub.com Fallback** ⚠️