Page 1 of 1

SEARCH for multiple strings

Posted: Thu Aug 16, 2018 5:45 am
by steved
MATCHES is using a regex that looks for 2 strings, "40" and "GS".

Code: Select all

REL{TUP{ID 1,A "5A053"}, TUP{ID 2, A "64GS6"}, TUP{ID 3, A "YYYY"}, TUP{ID 4, A "X40F"}}  WHERE MATCHES(A,"(.*40.*)*(.*GS.*)*")  
It should return a tuple where it finds either string. And it does, returning ID 2 and ID 4.

Code: Select all

RELATION {ID INTEGER, A CHARACTER} {
         TUPLE {ID 2, A "64GS6"},
         TUPLE {ID 4, A "X40F"}}
Using the same regex I was hoping SEARCH would return a tuple where either string was found.

Code: Select all

 REL{TUP{ID 1,A "5A053"}, TUP{ID 2, A "64GS6"}, TUP{ID 3, A "YYYY"}, TUP{ID 4, A "X40F"}}  WHERE SEARCH(TUP{*},"(.*40.*)*(.*GS.*)*")
But in this case SEARCH is true for all tuples.

Code: Select all

 RELATION {ID INTEGER, A CHARACTER} {
      TUPLE {ID 1, A "5A053"},
      TUPLE {ID 2, A "64GS6"},
      TUPLE {ID 3, A "YYYY"},
      TUPLE {ID 4, A "X40F"}}
Of course using multiple SEARCH terms works.

Code: Select all

REL{TUP{ID 1,A "5A053"}, TUP{ID 2, A "64GS6"}, TUP{ID 3, A "YYYY"}, TUP{ID 4, A "X40F"}}  
           WHERE SEARCH(TUP{*},".*40.*") OR SEARCH(TUP{*}, ".*GS.*")
Is there any way, perhaps using another form of regex, to get a single SEARCH working looking for multiple strings?

Re: SEARCH for multiple strings

Posted: Thu Aug 16, 2018 5:24 pm
by Dave
I'd guess there is a different regex that would work. It's based on the Java regex syntax, which has some unique quirks.