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.
 +
The replace text and extract text functions support the use of regex.
 
</pre>
 
</pre>
The replace text and extract text functions support the use of regex.<br/>
+
 
<br/>'''Substring'''<br/>
+
'''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.)
<br/>'''Example Usage'''<br/>
 
"hello i am using macrodroid app"<br/>
 
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".<br/>
 
<br/>'''Replace all'''<br/>
 
Uses a regular expression to replace matching text with the supplied new text.<br/>
 
'''Example Usage'''<br/>
 
Source text = Hello, how are you?.
 
<br/>
 
the text to replace is "hello".<br/>
 
the new text is "hi"<br/>
 
The end result will be, "hi, how are you?".
 
  
<br/>'''Extract text'''<br/>
+
For example, in this string, 'hello I am using
Uses a regular expression to match and extract a section from the text.
+
the Macrodroid application', we can obtain the word 'Macrodroid' by using the initial position 17 and the last position 27.
<br/>'''Example Usage'''<br/>
+
</pre>
My phone number is 1234567890<br/>
+
 
Extract the expression "[0-9]".
+
'''Replace all'''
This will give a final result of the extraction of the phone number.
+
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
<br/>
+
The given function utilises a regular expression to substitute matching text with the provided new text.
<br/>'''Upper case'''<br/>
+
 
Converts the text to all upper case characters.<br/>
+
For instance, if
'''Example Usage'''<br/>
+
the source text is "Hello, how are you?"
Source text<br/>
+
let's change the text "Hello" (text to replace)
"Macrodroid is my app to automate my device".<br/>
+
by new text "Hi" then the final output will be 'Hi, how are you?'
Final result
+
</pre>
"MACRODROID IS MY APP TO AUTOMATE MY DEVICE".<br/>
+
 
<br/>'''Lower case'''<br/>
+
'''Extract text'''
Converts the text to all lower case characters.<br/>
+
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
'''Example Usage'''<br/>
+
A regular expression can be used to match and extract specific sections of text.
Source text<br/>
+
 
"MACRODROID IS MY APP TO AUTOMATE MY DEVICE".<br/>
+
For example, if the
Final result<br/>
+
text contains a phone number
"macrodroid is my app to automate my device".<br/>
+
such as 'My phone
<br/>'''Trim whitespace'''<br/>
+
number is 1234567890', the expression '[0-9]' can be used to extract only the digits and obtain the phone number.
Removes any leading/trailing whitespace from the text.<br/>
+
</pre>
<br/>'''Remove text'''<br/>
+
 
 +
'''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.
 +
 
 +
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
 
Remove text from some variable using plain text or Regex
<br/>'''Example Usage'''<br/>
+
 
Source text<br/>
+
Example Usage
 +
 
 +
Source text
 
the text to remove is "MACRODROID".
 
the text to remove is "MACRODROID".
"MACRODROID IS MY APP TO AUTOMATE MY DEVICE".<br/>
+
"MACRODROID IS MY APP TO AUTOMATE MY DEVICE".
Final result<br/>
+
Output text
" is my app to automate my device".<br/>
+
" is my app to automate my device".
 +
</pre>

Revision as of 23:02, 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
the text to remove is "MACRODROID".
"MACRODROID IS MY APP TO AUTOMATE MY DEVICE".
Output text
" is my app to automate my device".