// GraalJS Script (engine type: 2)
//
// Notes:
// Consecutive blanks (including tabs etc) are recognized as one blank in advance.
// Double quotes and single quotes have been removed in advance.
// Whitespaces at both ends have been removed in advance.
// Use C if you want to consider commas as delimiters.
// comma, period, semicolon, colon, question mark, exclamation mark
//
// Notes (ja):
// 連続する空白(改行・全角空白等も含む)は、あらかじめ全体で1つの空白と認識されます。
// ダブルクオートとシングルクオートは、あらかじめ除去されたものとします。
// 先頭と末尾の空白は、あらかじめ除去されたものとします。
// カンマ等も区切り文字と見なしたい場合はCを使用してください。
// カンマ、ピリオド、セミコロン、コロン、クエスチョンマーク、エクスクラメーションマーク
//////// START "main()" ////////////////////////////////////////////////////////////////
main();
function main(){
//// == Config Retrieving / 工程コンフィグの参照 ==
const strA = configs.get( "conf_StrA" ) + ""; // required
const dataIdB = configs.get( "conf_DataIdB" ) + ""; // not required
const dataIdC = configs.get( "conf_DataIdC" ) + ""; // not required
if( strA === "" ){
engine.log( " AutomatedTask StringWarning:" +
" Config {A} is empty" );
}
//// == Data Retrieving / ワークフローデータの参照 ==
// (nothing)
//// == Calculating / 演算 ==
const strB = strA.replace(/\s+/g," ").replace(/("|')/g, "").trim();
const strC = strB.replace(/(\,|\.|:|;|\!|\?|\s)+/g, " ").trim();
// Note) Tab and double byte space are included in "\s" (UTF-8)
// including space, tab, form feed, line feed, and other Unicode spaces.
const numB = strB.split(" ").length;
const numC = strC.split(" ").length;
//// == ワークフローデータへの代入 / Data Updating ==
if( dataIdB !== "" ){
engine.setDataByNumber( dataIdB, new java.math.BigDecimal( numB ) );
}
if( dataIdC !== "" ){
engine.setDataByNumber( dataIdC, new java.math.BigDecimal( numC ) );
}
} //////// END "main()" ////////////////////////////////////////////////////////////////
Pingback: String, Get Number of Characters – Questetra Support