Skip to main content
1-Visitor
August 27, 2019
Question

Matching string to a table of expressions

  • August 27, 2019
  • 1 reply
  • 1618 views

I would like to take an input string and check if it matches any expression in a DataTable of expressions.

 

For example, if the input string is "SomeError1", and the expressions in the DataTable are:

 

"SomeError.*"

"SomeOtherError.*"

".*Error"

 

I want to query if the input string matches any of the expressions in the table. In this case, it would match "SomeError.*".

 

I've tried querying the DataTable entries with LIKE and Matches queries:

 "filters": {
  "type": "Matches",
   "fieldName": "item",
   "expression": "SomeError1"
}

 

"filters": {
    "type": "LIKE",
    "fieldName": "item",
    "value": "SomeError1"
}

 

but it only returns a result if the value/expression field is the expression.

 

Is there any way to accomplish this?

 

Thanks!

1 reply

22-Sapphire I
August 28, 2019

Perhaps you can add a wild card to your search: When using LIKE/NOTLIKE you need to add your own Wild Cards (% or * or ? for a single character wild card). For example to find ThingWorx use LIKE Th%

 

http://support.ptc.com/help/thingworx_hc/thingworx_8_hc/en/#page/ThingWorx%2FHelp%2FComposer%2FThings%2FThingServices%2FQueryParameterforQueryServices.html

iabshire1-VisitorAuthor
1-Visitor
August 28, 2019

Thanks for the reply, but I'm trying to do the opposite. The search string is the full string and I want to check if it matches any expression (with wildcards) in the table.

22-Sapphire I
August 28, 2019

I don't think there is a set query for that, you probably have to loop through your table and just execute a javascript search