Clean a text file in two steps
Convert order labels to Order 0042 pending and Order 0187 sent without joining their lines.
This workflow loads a text file into a two-layer substitution pipeline, then copies the result and saves the pipeline.
Pipelines require Pro on the public service, or the Substitution Pipeline add-on in Enterprise. Single text-file loading is included in Free. A Free alternative is described below.
Load the source file
Create a UTF-8 text file named orders.txt with these two lines:
ORD-0042 pending
ORD-0187 sent
- Open Pipeline in the editor sidebar.
- Select Add substitution layer.
- Select JavaScript for Layer 1.
- Drag
orders.txtinto the first layer's empty Test String field. - Verify that both lines and the extra spaces appear in the input.
The first layer owns the editable input. Later layers receive read-only output from the preceding layer. A final line break in the file remains in the output.
Rename the prefix
In Layer 1, enter:
| Control | Value |
|---|---|
| Regular Expression | \bORD-([0-9]{4})\b |
| Flags | g |
| Substitution | Order $1 |
Press Ctrl+Enter on Windows or Linux, or Command+Enter on macOS.
The layer makes two replacements:
Order 0042 pending
Order 0187 sent
$1 keeps the four captured digits. The spaces before each status are outside the match, so they remain unchanged.
Normalize spaces and tabs
- Open Pipeline actions > Add substitution layer.
- Select the new layer and keep JavaScript.
- Enter
[ \t]+as the pattern and enable onlyg. - Enter one space as the substitution.
- Run the pipeline with
Ctrl+EnterorCommand+Enter.
Output From Layer 1 shows the intermediate text. The second layer produces:
Order 0042 pending
Order 0187 sent
The second layer makes four replacements: two spaces after Order and two longer spaces before the status words.
Pipeline Summary reports six replacements across both layers.
[ \t]+ matches spaces and tabs. Using \s+ here would also replace the line break between the records.
Inspect and copy the result
- Select Layer 2 and inspect its Output.
- Select the copy button beside Output.
- Paste the text into a new file named
orders-clean.txt. - Compare the pasted text with the two-line result above.
To inspect the contribution of the second layer, open its tab menu and disable it. The output then retains the extra spaces. Enable it and run again to restore the normalized result.
A failed layer blocks later layers. If a layer contains an error such as [, correct it and rerun before copying output.
The pipeline reference describes layer states and execution controls.
Save the reusable pipeline
- Sign in and select Save & Share > Save Workspace.
- Copy the Access Link.
- Reopen the link. Both layers and the original file text are restored.
- Run the pipeline and verify the final two-line result.
- Use Manage Workspace > Edit Title and Tags to name it
Order label cleanup.
The saved workspace contains the extracted text and layer configuration. It does not reopen or watch the original file on disk. Use Update Workspace after editing a saved pipeline to keep another version.
Apply the same steps without a pipeline
With Free, use Substitution mode for the prefix replacement. Copy its output into Test String, then apply the spacing replacement. The two operations produce the same result but are separate editor runs.
The equivalent JavaScript is:
const input = 'ORD-0042 pending\nORD-0187 sent'
const renamed = input.replace(/\bORD-([0-9]{4})\b/g, 'Order $1')
const output = renamed.replace(/[ \t]+/g, ' ')
console.log(output)
// Order 0042 pending
// Order 0187 sent
The prefix pattern leaves ORD-42 unchanged. An empty input produces an empty result.