#Multiline-String: Remove Blank Lines
Deletes blank lines. There are two modes: delete all blank lines and combine consecutive blank lines into one line.
Configs for this Auto Step
- StrConfA
- A: Set Text *#{EL}
- BoolConfB
- B: Delete All Blank Lines or Combine into One
- SelectConfC
- C: Select STRING DATA to store Deleted Text (update) *
- SelectConfD1
- D1: Select NUMERIC for Number of Text Lines (update)
Script (click to open)
// Script Example of Business Process Automation
// for 'engine type: 3' ("GraalJS standard mode")
// cf. 'engine type: 2' ("GraalJS Nashorn compatible mode") (renamed from "GraalJS" at 20230526)
//////// START "main()" /////////////////////////////////////////////////////////////////
main();
function main(){
//// == Config Retrieving / 工程コンフィグの参照 ==
const strInput = configs.get ( "StrConfA" ); // REQUIRED
if( strInput === "" ){
throw new Error( "\n AutomatedTask ConfigError:" +
" Config {A: InputText} is empty \n" );
}
const numInputLines = strInput.split("\n").length;
const boolCombine = configs.getObject ( "BoolConfB" ); // TOGGLE
// https://questetra.zendesk.com/hc/ja/articles/360024574471-R2300 "Boolean object"
const strPocketC = configs.getObject ( "SelectConfC" ); // REQUIRED
const numPocketD1 = configs.getObject ( "SelectConfD1" ); // not required
//// == Data Retrieving / ワークフローデータの参照 ==
// (nothing)
//// == Calculating / 演算 ==
let strOutput = boolCombine ? // Conditional Operator
strInput.replace(/(\r\n){3,}|\r{3,}|\n{3,}/g, '\n\n') : // true
strInput.replace(/(\r\n){2,}|\r{2,}|\n{2,}/g, '\n') ; // false
//// == Data Updating / ワークフローデータへの代入 ==
/// ref) Retrieving / Updating from ScriptTasks
/// https://questetra.zendesk.com/hc/en-us/articles/360024574771-R2301
/// https://questetra.zendesk.com/hc/ja/articles/360024574771-R2301
if ( strPocketC !== null ){
engine.setData( strPocketC, strOutput );
}
if ( numPocketD1 !== null ){
engine.setData( numPocketD1, new java.math.BigDecimal( numInputLines ) );
}
} //////// END "main()" /////////////////////////////////////////////////////////////////
/*
NOTES
- The Process reaches this [Automated Step], the "Remove Blank Lines" is automatically executed.
- Consecutive line break codes in the input text will be replaced.
- The number of lines in the input text can also be recorded.
NOTES-ja
- この[自動工程]に案件が到達すると、「空行削除」が自動実行されます。
- Inputテキスト内にある「連続改行コード」が置換されます。
- 入力Inputテキストの行数も記録可能です。
▼Test Data for Debug:
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
APPENDIX
- A line containing only whitespace characters is not considered a blank line.
- 「空白文字のみの行」は空行とはみなされません。
*/
Download
- multiline-string-remove-blank-lines-2025.xml
- 2025-05-07 (C) Questetra, Inc. (MIT License)
Freely modifiable JavaScript (ECMAScript) code. No warranty of any kind.
(Installing Addon Auto-Steps are available only on the Professional edition.)
(Installing Addon Auto-Steps are available only on the Professional edition.)
Notes
- When a Process reaches this [Automated Step], blank lines will be deleted automatically.
- Consecutive line break codes in the input text will be replaced.
- The number of lines in the input text can also be recorded.
- A line containing only whitespace characters is not considered a blank line.
Capture


