「新規行番号入力」の版間の差分
変数の宣言を分割 |
ソースコードを整形 |
||
| 8行目: | 8行目: | ||
=== ソースコード === | === ソースコード === | ||
<syntaxhighlight lang="javascript" copy> | <syntaxhighlight lang="javascript" copy> | ||
//全消去 | // 全消去 | ||
document.selection.SelectAll(); | document.selection.SelectAll(); | ||
document.selection.DeleteLeft(1); | document.selection.DeleteLeft(1); | ||
var r = new RegExp(prompt("整数2桁までを入力してください", "")); | var r = new RegExp(prompt("整数2桁までを入力してください", "")); | ||
//値の取得 | // 値の取得 | ||
document.selection.Text = r; | document.selection.Text = r; | ||
document.selection.Replace("/", "", meFindNext | meReplaceAll); | document.selection.Replace("/", "", meFindNext | meReplaceAll); | ||
| 22行目: | 22行目: | ||
let x = 0; | let x = 0; | ||
for (let step = 0; step < j; step++) { | for (let step = 0; step < j; step++) { | ||
// 値が 0 から jまで実行される | |||
x = step + 1; | |||
document.selection.Text = x; | document.selection.Text = x; | ||
document.selection.Text = "."; | document.selection.Text = "."; | ||
| 39行目: | 39行目: | ||
<syntaxhighlight lang="javascript" copy> | <syntaxhighlight lang="javascript" copy> | ||
var r = Prompt("整数を入力してください", "") | var r = Prompt("整数を入力してください", "") | ||
.replace(/[0-9]/g, function(tmp) { | |||
return String.fromCharCode(tmp.charCodeAt(0) - 0xFEE0); | |||
}).replace(/\D/g, ""); | |||
if (r) { | if (r) { | ||
var r1 = ""; | |||
var r2 = ""; | |||
var str = ""; | |||
// r1 = Prompt("数字の前に追加したい文字列を入力してください", ""); | |||
r2 = Prompt("数字の後ろに追加したい文字列を入力してください", ""); | |||
for (var i = 1; i <= +r; i++) { | |||
str += r1 + i + r2 + "\n"; | |||
} | |||
Document.Text = str.replace(/\n$/, ""); | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
スポンサーリンク