SEARCH for multiple strings

This forum is for any questions about the language Tutorial D or the Rel implementation of it.
Post Reply
steved
Posts: 49
Joined: Sun Sep 01, 2013 10:53 pm

SEARCH for multiple strings

Post by steved » Thu Aug 16, 2018 5:45 am

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?

Dave
Site Admin
Posts: 364
Joined: Sun Nov 27, 2005 7:19 pm

Re: SEARCH for multiple strings

Post by Dave » Thu Aug 16, 2018 5:24 pm

I'd guess there is a different regex that would work. It's based on the Java regex syntax, which has some unique quirks.

Post Reply