Difference between revisions of "Action: Text Manipulation"
Tags: Mobile web edit Mobile edit |
m |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | This action can be used to perform basic string manipulation on a text string.< | + | <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. | |
+ | The replace text and extract text functions support the use of regex. | ||
+ | </pre> | ||
+ | |||
+ | '''Substring''' | ||
+ | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;"> | ||
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.) | 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.) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | < | + | For example, in this string, 'hello I am using |
− | + | the Macrodroid application', we can obtain the word 'Macrodroid' by using the initial position 17 and the last position 27. | |
− | < | + | </pre> |
− | My phone number is 1234567890 | + | |
− | + | '''Replace all''' | |
− | + | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;"> | |
− | < | + | The given function utilises a regular expression to substitute matching text with the provided new text. |
− | + | ||
− | Converts the text to all | + | For instance, if |
− | + | the source text is "Hello, how are you?" | |
− | Source text | + | let's change the text "Hello" (text to replace) |
− | "Macrodroid is my | + | by new text "Hi" then the final output will be 'Hi, how are you?' |
− | + | </pre> | |
− | "MACRODROID IS MY APP TO AUTOMATE MY DEVICE".< | + | |
− | + | '''Extract text''' | |
− | Converts the text to all lower case characters. | + | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;"> |
− | + | A regular expression can be used to match and extract specific sections of text. | |
− | Source text | + | |
− | "MACRODROID IS MY APP TO AUTOMATE MY DEVICE". | + | For example, if the |
− | + | text contains a phone number | |
− | "macrodroid is my app to automate my device".< | + | such as 'My phone |
− | + | number is 1234567890', the expression '[0-9]' can be used to extract only the digits and obtain the phone number. | |
+ | </pre> | ||
+ | |||
+ | '''Upper case''' | ||
+ | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;"> | ||
+ | Converts the text to all uppercase letters. | ||
+ | |||
+ | Example of use | ||
+ | Source text "Macrodroid is my application to automate my device". | ||
+ | Output text | ||
+ | "MACRODROID IS MY APP TO AUTOMATE MY DEVICE". | ||
+ | </pre> | ||
+ | |||
+ | '''Lower case''' | ||
+ | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;"> | ||
+ | Converts the text to all lower case characters. | ||
+ | |||
+ | Example Usage | ||
+ | Source text | ||
+ | "MACRODROID IS MY APP TO AUTOMATE MY DEVICE". | ||
+ | Output text | ||
+ | "macrodroid is my app to automate my device". | ||
+ | </pre> | ||
+ | |||
+ | '''Trim whitespace''' | ||
+ | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;"> | ||
Removes any leading/trailing whitespace from the text. | Removes any leading/trailing whitespace from the text. | ||
+ | |||
+ | Example Usage | ||
+ | |||
+ | Source text | ||
+ | "macrodroid is my app to automate my device". | ||
+ | Output text | ||
+ | "macrodroidismyapptoautomatemydevice". | ||
+ | </pre> | ||
+ | |||
+ | '''Remove text''' | ||
+ | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;"> | ||
+ | Remove text from some variable using plain text or Regex | ||
+ | |||
+ | Example Usage | ||
+ | |||
+ | Source text "MACRODROID IS MY APP TO AUTOMATE MY DEVICE". | ||
+ | the text to remove is "MACRODROID". | ||
+ | Output text | ||
+ | " is my app to automate my device". | ||
+ | </pre> |
Latest revision as of 23:03, 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.) For example, in this string, 'hello I am using the Macrodroid application', we can obtain the word 'Macrodroid' by using the initial position 17 and the last position 27.
Replace all
The given function utilises a regular expression to substitute matching text with the provided new text. For instance, if the source text is "Hello, how are you?" let's change the text "Hello" (text to replace) by new text "Hi" then the final output will be 'Hi, how are you?'
Extract text
A regular expression can be used to match and extract specific sections of text. For example, if the text contains a phone number such as 'My phone number is 1234567890', the expression '[0-9]' can be used to extract only the digits and obtain the phone number.
Upper case
Converts the text to all uppercase letters. Example of use Source text "Macrodroid is my application to automate my device". Output text "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". Output text "macrodroid is my app to automate my device".
Trim whitespace
Removes any leading/trailing whitespace from the text. Example Usage Source text "macrodroid is my app to automate my device". Output text "macrodroidismyapptoautomatemydevice".
Remove text
Remove text from some variable using plain text or Regex Example Usage Source text "MACRODROID IS MY APP TO AUTOMATE MY DEVICE". the text to remove is "MACRODROID". Output text " is my app to automate my device".