Difference between revisions of "Action: Text Manipulation"
m |
|||
Line 1: | Line 1: | ||
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;"> | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;"> | ||
− | This action can be used to perform basic string manipulation on a text string. | + | This action can be used to perform basic string manipulation on a text string. |
− | |||
</pre> | </pre> | ||
The replace text and extract text functions support the use of regex.<br/> | The replace text and extract text functions support the use of regex.<br/> | ||
Line 40: | Line 39: | ||
"macrodroid is my app to automate my device".<br/> | "macrodroid is my app to automate my device".<br/> | ||
<br/>'''Trim whitespace'''<br/> | <br/>'''Trim whitespace'''<br/> | ||
− | Removes any leading/trailing whitespace from the text. | + | Removes any leading/trailing whitespace from the text.<br/> |
+ | <br/>'''Remove text'''<br/> | ||
+ | Remove text from some variable using plain text or Regex | ||
+ | <br/>'''Example Usage'''<br/> | ||
+ | Source text<br/> | ||
+ | the text to remove is "MACRODROID". | ||
+ | "MACRODROID IS MY APP TO AUTOMATE MY DEVICE".<br/> | ||
+ | Final result<br/> | ||
+ | " is my app to automate my device".<br/> |
Revision as of 22:37, 6 February 2024
This action can be used to perform basic string manipulation on a text string.
The replace text and extract text functions support the use of regex.
Substring
Returns a sub-section of the text defined by the supplied start and end indexes. The first character starts at index 0 and the last index is excluded. (To get the first character use values 0 and 1.)
Example Usage
"hello i am using macrodroid app"
To obtain the word Macrodroid we will use the initial position 17 and last position 27 and as a result we will have the value "Macrodroid".
Replace all
Uses a regular expression to replace matching text with the supplied new text.
Example Usage
Source text = Hello, how are you?.
the text to replace is "hello".
the new text is "hi"
The end result will be, "hi, how are you?".
Extract text
Uses a regular expression to match and extract a section from the text.
Example Usage
My phone number is 1234567890
Extract the expression "[0-9]".
This will give a final result of the extraction of the phone number.
Upper case
Converts the text to all upper case characters.
Example Usage
Source text
"Macrodroid is my app to automate my device".
Final result
"MACRODROID IS MY APP TO AUTOMATE MY DEVICE".
Lower case
Converts the text to all lower case characters.
Example Usage
Source text
"MACRODROID IS MY APP TO AUTOMATE MY DEVICE".
Final result
"macrodroid is my app to automate my device".
Trim whitespace
Removes any leading/trailing whitespace from the text.
Remove text
Remove text from some variable using plain text or Regex
Example Usage
Source text
the text to remove is "MACRODROID".
"MACRODROID IS MY APP TO AUTOMATE MY DEVICE".
Final result
" is my app to automate my device".