Match
Last updated
Last updated
Match
Matches a regular expression and extracts a specific value (if matched). @param expression type string. Regular expression @param flags List of optional flags (A I M L S X) Input must be a string. I - IGNORE THE CASE A - ASCII L - LOCALE X - VERBOSE M - MULTILINE MATCH S - '.' matches all (otherwise regex has a limited set of chars where it matches with )
This function allows users to search for a match using regular expressions within a given dataset.
Step 1: Create an empty match_example_1 using AIOps studio as shown in the below screenshot.
Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:
You can copy the below code into your pipeline and execute that in your environment.
##### This pipeline creates a list of rows with hostname and ipaddress
##### RDA dm function 'match' used to demo this example. In this pipeline, each row added
##### has a column with IPAddress and hostname.
##### Pipeline uses RDA dm function match to match to regular expression to pick only
##### ipaddresses.
@dm:empty
--> @dm:addrow id = 'a1' & APP_Client_FQDN = "host1.acme.com"
--> @dm:addrow id = 'a2' & APP_Client_FQDN = "host2.acme.com"
--> @dm:addrow id = 'a3' & APP_Client_FQDN = "host3.acme.com"
--> @dm:addrow id = 'a4' & APP_Client_FQDN = "172.17.0.1"
--> @dm:addrow id = 'a5' & APP_Client_FQDN = "192.168.60.120"
--> @dm:addrow id = 'a6' & APP_Client_FQDN = "172.17.0.4"
--> @dm:addrow id = 'a7' & APP_Client_FQDN = "172.17.0.3"
--> @dm:map func = 'match' & from = 'APP_Client_FQDN' & to = 'IPaddress' & expr = "^(?:[0-9]{1,3}.){3}[0-9]{1,3}$"
Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)
Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)
Step 5: RDA uses the 'match' function to match a regular expression from a selected column, picks up that value, applies regular expression, stores it in the new column (IP Address), and prints it to the screen as shown below.
Step 1: Create an empty match_example_2 using AIOps studio as shown in the below screenshot.
Step 2: Add the following pipeline code/commands into the above-created pipeline as shown in the below screenshot:
You can copy the below code into your pipeline and execute that in your environment.
##### This pipeline creates a list of rows with hostname and ipaddress
##### RDA dm function 'match' used to demo this example. In this pipeline, each row added
##### has a column with IPAddress and hostname.
##### Pipeline uses RDA dm function match to match to regular expression to pick only
##### hostname from FQDN from the dataset.
@dm:empty
--> @dm:addrow id = 'a1' & APP_Client_FQDN = "host1.acme.com"
--> @dm:addrow id = 'a2' & APP_Client_FQDN = "host2.acme.com"
--> @dm:addrow id = 'a3' & APP_Client_FQDN = "host3.acme.com"
--> @dm:addrow id = 'a4' & APP_Client_FQDN = "172.17.0.1"
--> @dm:addrow id = 'a5' & APP_Client_FQDN = "192.168.60.120"
--> @dm:addrow id = 'a6' & APP_Client_FQDN = "172.17.0.4"
--> @dm:addrow id = 'a7' & APP_Client_FQDN = "172.17.0.3"
--> @dm:map func = 'match' & from = 'APP_Client_FQDN' & to = 'Hostname' & expr = "(.*).acme.com"
Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)
Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)
Step 5: RDA uses the 'match' function to match a regular expression from a selected column, picks up that value, applies regular expression, stores it in the new column (hostname), and prints it to the screen as shown below.
Step 1: Create an empty match_example_3 using AIOps studio as shown in the below screenshot.
You can copy the below code into your pipeline and execute that in your environment.
##### This pipeline creates a list of rows with hostname and ipaddress
##### RDA dm function 'match' used to demo this example. In this pipeline, each row added
##### has a column with IPAddress and hostname.
##### Pipeline uses RDA dm function match to match to regular expression to pick FQDN
##### and excluding IP Addresses from the dataset.
@dm:empty
--> @dm:addrow id = 'a1' & APP_Client_FQDN = "host1.acme.com"
--> @dm:addrow id = 'a2' & APP_Client_FQDN = "host2.acme.com"
--> @dm:addrow id = 'a3' & APP_Client_FQDN = "host3.acme.com"
--> @dm:addrow id = 'a4' & APP_Client_FQDN = "172.17.0.1"
--> @dm:addrow id = 'a5' & APP_Client_FQDN = "192.168.60.120"
--> @dm:addrow id = 'a6' & APP_Client_FQDN = "172.17.0.4"
--> @dm:addrow id = 'a7' & APP_Client_FQDN = "172.17.0.3"
--> @dm:map func = 'match' & from = 'APP_Client_FQDN' & to = 'Hostname' & expr =
"^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$"
Step 3: Click verify button to make sure syntax and pipeline code is correct (as shown below)
Step 4: Click execute button and execute the pipeline. RDA will execute the pipeline without any errors (as shown below)
Step 5: RDA uses the 'match' function to match a regular expression from a selected column, picks up that value, applies regular expression, stores it in the new column (FQDN - hostname.domain), and prints it to the screen as shown below.
Note: Each of the above examples is using different expressions (regular expressions) to extract patterns to match criteria and output required data from the dataset. Also, you can remove the rows with 'None' values using the dm function "@dm:fixnull columns = 'Hostname'"