「テキスト変換」の版間の差分
句読点の修正 |
SyntaxHighlightにcopyの追加 |
||
| (同じ利用者による、間の8版が非表示) | |||
| 5行目: | 5行目: | ||
* 機能追加が簡単。 | * 機能追加が簡単。 | ||
== | == 変更履歴 == | ||
* 2013 | * 1.0.2 (2013-01-25) | ||
* 2013 | ** 簡易表記対応 | ||
* 2013 | * 1.0.1 (2013-01-24) | ||
** グルーピング対応。replaceS、replaceL 対応 | |||
* 1.0.0 (2013-01-23) | |||
** 初版 | |||
== 使用方法 == | == 使用方法 == | ||
| 22行目: | 25行目: | ||
# セパレータの挿入<br><code>f[f.length] = "--";</code><br>でセパレータを挿入できます(- の数は任意)。 | # セパレータの挿入<br><code>f[f.length] = "--";</code><br>でセパレータを挿入できます(- の数は任意)。 | ||
# グルーピング<br>下のコードで、グルーピングができます。 | # グルーピング<br>下のコードで、グルーピングができます。 | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = [ "グループ名", function(f){ // <= グルーピング開始 | f[f.length] = [ "グループ名", function(f){ // <= グルーピング開始 | ||
f[f.length] = { // <= 以降はグルーピングされる機能を追加 | f[f.length] = { // <= 以降はグルーピングされる機能を追加 | ||
| 35行目: | 38行目: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 基本コード == | |||
<syntaxhighlight lang="javascript" copy> | |||
<syntaxhighlight lang="javascript"> | |||
#title = "テキスト変換" | #title = "テキスト変換" | ||
// ----------------------------------------------------------------------------- | // ----------------------------------------------------------------------------- | ||
| 186行目: | 188行目: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 拡張コード == | |||
'''ご自由に追加してください!''' | '''ご自由に追加してください!''' | ||
| 193行目: | 195行目: | ||
管理のしやすさから、1行にまとめている方をお勧めします。 | 管理のしやすさから、1行にまとめている方をお勧めします。 | ||
=== 空白削除 === | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = [ "空白削除", function(f){ | f[f.length] = [ "空白削除", function(f){ | ||
f[f.length] = [ "行頭の空白文字を削除", "", function(a){return a.replace(/^[ \t ]+/mg,"")} ]; | f[f.length] = [ "行頭の空白文字を削除", "", function(a){return a.replace(/^[ \t ]+/mg,"")} ]; | ||
| 203行目: | 205行目: | ||
}]; | }]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = { | f[f.length] = { | ||
title:"空白削除", | title:"空白削除", | ||
| 231行目: | 233行目: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 文字変換 === | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = [ "文字変換", function(f){ | f[f.length] = [ "文字変換", function(f){ | ||
f[f.length] = [ "大文字に変換", "", function(a){return a.toUpperCase()} ]; | f[f.length] = [ "大文字に変換", "", function(a){return a.toUpperCase()} ]; | ||
| 249行目: | 251行目: | ||
}]; | }]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = { | f[f.length] = { | ||
title:"文字変換", | title:"文字変換", | ||
| 305行目: | 307行目: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== ソート === | |||
「[[昇順で並び替え]]」「[[降順で並び替え]]」の移植です。 | 「[[昇順で並び替え]]」「[[降順で並び替え]]」の移植です。 | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = [ "ソート", function(f){ | f[f.length] = [ "ソート", function(f){ | ||
f[f.length] = [ "昇順ソート(文字列)", "S", function(a){return a.split("\n").sort().join("\n")} ]; | f[f.length] = [ "昇順ソート(文字列)", "S", function(a){return a.split("\n").sort().join("\n")} ]; | ||
| 313行目: | 315行目: | ||
}]; | }]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = { | f[f.length] = { | ||
title:"ソート", | title:"ソート", | ||
| 329行目: | 331行目: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== 行操作 === | |||
「[[連続する重複行を削除]]」の移植を含みます。 | 「[[連続する重複行を削除]]」の移植を含みます。 | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = [ "行操作", function(f){ | f[f.length] = [ "行操作", function(f){ | ||
f[f.length] = [ "文字列追加", function(f){ | f[f.length] = [ "文字列追加", function(f){ | ||
| 347行目: | 349行目: | ||
}]; | }]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = { | f[f.length] = { | ||
title:"行操作", | title:"行操作", | ||
| 452行目: | 454行目: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== グルーピング === | |||
選択範囲を簡易的にグルーピングします。 | 選択範囲を簡易的にグルーピングします。 | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = [ "機能のグルーピング", "S", function(a){var b=Prompt("グループ名","");if(!b){Quit()}var c=a.match(/^\s*/);var d="\t";return c+'f[f.length] = [ "'+b+'", function(f){\n'+d+a.split("\n").join("\n"+d)+"\n"+c+"}];"} ]; | f[f.length] = [ "機能のグルーピング", "S", function(a){var b=Prompt("グループ名","");if(!b){Quit()}var c=a.match(/^\s*/);var d="\t";return c+'f[f.length] = [ "'+b+'", function(f){\n'+d+a.split("\n").join("\n"+d)+"\n"+c+"}];"} ]; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = { | f[f.length] = { | ||
title:"機能のグルーピング", | title:"機能のグルーピング", | ||
| 470行目: | 472行目: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== BASE64エンコード(Unicode) === | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = { | f[f.length] = { | ||
title:"BASE64エンコード(Unicode)", | title:"BASE64エンコード(Unicode)", | ||
| 497行目: | 499行目: | ||
=== replace === | === replace === | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
function replace( | function replace( | ||
text : string, | text : string, | ||
| 512行目: | 514行目: | ||
=== replaceS === | === replaceS === | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
function replaceS( | function replaceS( | ||
text : string, | text : string, | ||
| 521行目: | 523行目: | ||
行は論理行で処理しますが、下記のように <code>view:true</code> を定義時に登録することで、表示行で処理することもできます。 | 行は論理行で処理しますが、下記のように <code>view:true</code> を定義時に登録することで、表示行で処理することもできます。 | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = { | f[f.length] = { | ||
title:"replaceL", | title:"replaceL", | ||
| 530行目: | 532行目: | ||
=== replaceL === | === replaceL === | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
function replaceL( | function replaceL( | ||
text : string, | text : string, | ||
| 543行目: | 545行目: | ||
次の 2 つの定義は同じ処理(空白行削除)をします。 | 次の 2 つの定義は同じ処理(空白行削除)をします。 | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
replaceS:function(text){ return text.replace(/^\n/mg, "") } | replaceS:function(text){ return text.replace(/^\n/mg, "") } | ||
replaceL:function(text){ if (text != "") { return text } } | replaceL:function(text){ if (text != "") { return text } } | ||
| 557行目: | 559行目: | ||
配列の形式で記述し、 | 配列の形式で記述し、 | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
f[f.length] = [ "機能名", "関数タイプ", function(text){ return text; }, isView | f[f.length] = [ "機能名", "関数タイプ", function(text){ return text; }, isView | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| 570行目: | 572行目: | ||
関数部分はクリップボードにコピーされるため、そのまま貼り付けるか、[http://dean.edwards.name/packer/ packer] などを利用して圧縮して貼り付けてください。 | 関数部分はクリップボードにコピーされるため、そのまま貼り付けるか、[http://dean.edwards.name/packer/ packer] などを利用して圧縮して貼り付けてください。 | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript" copy> | ||
// 関数の簡易表現化 | // 関数の簡易表現化 | ||
// 関数部分はクリップボードにコピーする | // 関数部分はクリップボードにコピーする | ||
スポンサーリンク