PARSE - < text_parse >() ... [Pro]
Variable PARSE <text_parse>("Input text/variable","Pattern","Variable for matching elements","Variable for number of matching elements","Additional options") Available in: Professional edition
|
This command parses input text to multiple pieces based on the pattern provided. The pattern consists of asterisks (*) and delimter substrings. The parses extracts the parts of the text that correspond to asterisks. Example: Input text: Customer info: Name: John Smith Phone: +001 564123123 Email: jsmith@email.com Pattern:Name:*Phone:*Email:* Data extracted by parser as result: John Smith, +001 564123123, jsmith@email.com
|
#
|
Parameter name
|
Parameter description
|
1
|
Input text/variable
|
Input text or variable (such as %vInputText%)
|
2
|
Pattern
|
Pattern or variable containing pattern text
|
3
|
Variable for matching elements
|
Name of the array variable that will receive the parsed out pieces of the input text
|
4
|
Variable for number of matching elements
|
Name of the variable that contains number of items in the array variable
|
5
|
Additional options
|
Parse options (options are case sensitive): -nc - Not case sensitive when matching delimiter substrings. -tl - trim left. Spaces, tabs, new lines are removed from the beggining of the parsed out pieces. -tr - trim right. Spaces, tabs, new lines are removed from the end of the parsed out pieces. -rp - Repeat pattern
|
|
|
Example (Macro Steps):
|
1
|
<#> <#> This example demonstrates how to use "text parse" command
|
2
|
Variable SET "vInput=Customers info: Name: John Smith Phone: +001 564123123 Email: jsmith@email.com Name: Jack Back Phone: +002 779835 Email: jb@comp.com", Message text=""
|
3
|
Variable PARSE Input text/variable = %vInput%, Pattern = name:*phone:*email:*, Variable for matching elements = vItems, Variable for number of matching elements = vItemsSize, Additional options = -nc -tl -tr -rp
|
4
|
Message SHOW "Information" : "Input text is: %vInput%" (other parameters: x = -100, y = -100, Window title = , Buttons = OK, Timeout (seconds) = 0, Always on top = No).
|
5
|
Message SHOW "Information" : "%vItemsSize% items retrieved: %vItems[0]% %vItems[1]% %vItems[2]% %vItems[3]% %vItems[4]% %vItems[5]% " (other parameters: x = -100, y = -100, Window title = , Buttons = OK, Timeout (seconds) = 0, Always on top = No).
|
|
Example (Plain Text):
<#> This example demonstrates how to use "text parse" command
<#>
<varset>("vInput=Customers info:
Name: John Smith
Phone: +001 564123123
Email: jsmith@email.com
Name: Jack Back
Phone: +002 779835
Email: jb@comp.com","")<#>
<text_parse>("%vInput%","name:*phone:*email:*","vItems","vItemsSize","-nc -tl -tr -rp","p6")<#>
<msg>(-100,-100,"Input text is:
%vInput%","",1,0,0,0)<#>
<msg>(-100,-100,"%vItemsSize% items retrieved:
%vItems[0]%
%vItems[1]%
%vItems[2]%
%vItems[3]%
%vItems[4]%
%vItems[5]%
","",1,0,0,0)