LoginSignup
0
0

More than 1 year has passed since last update.

テロップ文字数制限チェック

Posted at

クライアントから頂いたテキストデータで文字制限ありで依頼してても
「ん?何行目が文字数オーバーしてますか?」
という事あるよね?
ん??みんなあるよね??

わかりました。こちらでその作業致しますね!!
任せて下さい!!こっちでやる事では無いですけど…(ごにょごにょ…ボソボソ…)
あっ…大丈夫です!!
任せて下さい!!
って時に出来る感を出すために素早く対処

参考にさせていただいたURL

追加分

var mytextArray  = []; 
var seigen = 19;

//ファイルを読み込んで配列に入れる作業
function readtext(){
var fileName = File.openDialog("Select Text file","");
var myFile = new File(fileName);
    if (myFile.open("r")){
    var myText = "";
        while(!myFile.eof){
        var myText = myText + myFile.readln()  + String.fromCharCode(13);
        }
        var text_array=myText.split (String.fromCharCode(13));
            for(var i=0; i<(text_array.length-1); i++){
               mytextArray.push(text_array[i]);
            }
    }
myFile.close();
}
readtext()

function count(n) {
    var nagasa = 0;
    for (j = 0; j < n.length; j++) {
        if(n[j].match(/[ -~]/) ) {
            nagasa += 0.5;
        }
        else {
            nagasa += 1;
        }
    }
    return nagasa;
}


for( var i=0; i< mytextArray.length; i++ ){
    if ( count(mytextArray[i]) > seigen ){
        $.writeln( (i+1)+"行目")
        $.writeln( mytextArray[i] )
        $.writeln( count(mytextArray[i])+"文字" )
    }
}





0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0