Basic usage of String Maniplulation
NAME
String Manipulation is used to Find/Relace/Split a word in a string or a text file with Regular Expression
SYNOPSYS
String Manipulation needs next parameters or options.
Parameters
String operations
- Type of operations
- Support operations: Find, Replace, and Split
Regular Expression
- a pattern or a word to operate (pattern for Regular Expression)
※ refer to Regular expression operations
String to handle
- a source string
String from file
- a source filename when using a file instead of a string (Text file only)
Get Length
- Get the number of times a match occurred
Options
String to replace
- It literally means 'string to replace'
Ignore Case
- case insensitive pattern is applied.
Set number of …
- the iteration limit of 'operation' to be applied the results of matching
- Default: 0 (no limit)
- Example
Total matching is “5”, and If you set this “1”, this operation will be applied on the 1st matching.
EXAMPLES
EX1. Gets the number of occurrences of the word 'bear' in the string.
Parameters
Parameters/Options | Value |
---|---|
String operation | find |
Regular Expression | bear |
String to handle | The bear and the maiden fair. |
Get Length | Checked |
Results
- 1
- 'bear' is found just once in a string.
EX2. Gets the number of occurrences of the word 'lann*' in the string.
Sample text file
- Filename:
Game_of_thrones.txt
- Contents:
The bear and the maiden fair. The night is dark and full of terrors. A Lannister always pays his debts. What is dead may never die. May the Father judge him justly. Bastards are born of passion, aren't they? We don't despise them in Dorne. Unbowed, Unbent, Unbroken. A Lannister always pays his debts. The tourney of Ashford Meadows. When you play the game of thrones, you win or you die.
Parameters
Parameters/Options | Value |
---|---|
String operation | find |
Regular Expression | lann* |
String from file | C:\TestRun\Game_of_thrones.txt |
Get Length | Checked |
Ignore Case | checked |
Results
- 2
- There are two lines in the file that contain 'Lannister'.
EX3. Replace a word in a file
Parameters
Parameters/Options | Value |
---|---|
String operation | replace |
Regular Expression | lann* |
String from file | C:\TestRun\Game_of_thrones.txt |
String to replace | Stark |
Ignore Case | checked |
Results type | File |
File Path | C:\TestRun\Replace_output.txt |
Variable name | {{g1.v1}} |
You have to define a UserVariable first to store the replace results.
ex) {{g1.v1}}
Results
- All 'Lannister' changed to 'Stark'.
The bear and the maiden fair. The night is dark and full of terrors. A Stark always pays his debts. What is dead may never die. May the Father judge him justly. Bastards are born of passion, aren't they? We don't despise them in Dorne. Unbowed, Unbent, Unbroken. A Stark always pays his debts. The tourney of Ashford Meadows. When you play the game of thrones, you win or you die.
EX4. Split a word by SPACE (\s).
Parameters
Parameters/Options | Value |
---|---|
String operation | split |
Regular Expression | \s |
String to handle | The bear and the maiden fair. |
Results
The
bear
and
the
maiden
fair.
PLATFORM
Here is the supported platform for this plugin.
- This plugin support Windows 10 and above.
- This plugin support Linux (Ubuntu).
- This plugin support Mac.
Version
- 1.522.1442