object.find ctrl
code:Lua
s, e = textmodule.object.find_ctrl(str, idx)
モジュール
引数
table:_
変数 型 概要
1 str string 元の文字列
2 n number 制御文字の番号
返り値
table:_
変数 型 概要
1 s number 制御文字の開始位置
2 e number 制御文字の終了位置
概要
strに含まれる制御文字を検索し、その開始位置と終了位置を返す。 見つからなかった場合は、なにも値を返さない。
nを1以上に指定すると、n番目の制御文字の位置を得る。
nを0に指定すると、文字列に含まれる制御文字の数を得る。
例
code:Lua
require("textmodule")
t = "これは<s32>テスト文字列<s>です。"
print("個数: ", textmodule.obj.find_ctrl(t, 0))
print("1番目: ", textmodule.obj.find_ctrl(t, 1))
print("2番目: ", textmodule.obj.find_ctrl(t, 2))
print("3番目: ", textmodule.obj.find_ctrl(t, 3))
code:Console
個数: 2
1番目: 4 8
2番目: 15 17
3番目: