Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7851717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:15:00+00:00 2026-06-02T19:15:00+00:00

The query criteria should support boolean operators and regular expressions. I’ve read about Booleano,

  • 0

The query criteria should support boolean operators and regular expressions. I’ve read about Booleano, but it doesn’t support regular expressions.

If there is nothing out there which matches this requirements, which would be the best technology to start building upon?

The grammar in the example below is just an example, but the feature it offers should exist.

is True if ('client/.+' and 'user_a') but (not 'limited' unless ('.+special' or 'godmode'))

which equals to

is True if 'client/.+' and 'user_a' and (not ('limited' and (not ('.+special' or 'godmode'))))

applied on the following lists

is_true  = ['client/chat', 'user_a', 'limited', 'extraspecial']
is_false = ['client/ping', 'user_a', 'limited']
is_false = ['server/chat']
is_false = ['server/ping', 'ping']
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:15:00+00:00Added an answer on June 2, 2026 at 7:15 pm

    I managed to solve the problem with the use of the pyparsing module.

    import re
    import pyparsing
    
    class BoolRegEx(object):
    
      def Match(self, tags=[], query=""):
        self.tags = tags
        if ' ' not in query:
          return self.Search(query)
        else:
          return pyparsing.operatorPrecedence(
            pyparsing.Word(pyparsing.printables, excludeChars="()"), [
              (pyparsing.Literal("NOT"), 1, pyparsing.opAssoc.RIGHT, self.Not),
              (pyparsing.Literal("OR"),  2, pyparsing.opAssoc.LEFT,  self.Or),
              (pyparsing.Literal("AND"), 2, pyparsing.opAssoc.LEFT,  self.And),
            ]
          ).parseString(query, parseAll=True)[0]
    
      def Search(self, a):
        try:
          regex = re.compile(a.replace("<<", "#~").replace(">>", "~#").replace(">", ")").replace("<", "(").replace("#~", "<").replace("~#", ">"))
          for tag in self.tags:
            match = regex.match(tag)
            if match and len(match.group(0)) == len(tag):
              return True
          return False
        except:
          raise
    
      def And(self, t):
        for a in t[0][0::2]:
          if isinstance(a, basestring):
            v = self.Search(a)
          else:
            v = bool(a)
          if not v:
            return False
        return True
    
      def Or(self, t):
        for a in t[0][0::2]:
          if isinstance(a, basestring):
            v = self.Search(a)
          else:
            v = bool(a)
          if v:
            return True
        return False
    
      def Not(self, t):
        a = t[0][1]
        if isinstance(a, basestring):
          return not self.Search(a)
        else:
          return not bool(a)
    
    print BoolRegEx().Match(['client/chat', 'user_a', 'limited', 'extraspecial'], "client/.+ AND user_a AND NOT ( limited AND NOT ( .+<r|i>special OR godmode ) )")
    # False
    
    print BoolRegEx().Match(['client/chat', 'user_a', 'limited', 'superspecial'], "client/.+ AND user_a AND NOT ( limited AND NOT ( .+<r|i>special OR godmode ) )")
    # True
    

    I had to replace the regexp () with <> in order to avoid collisions, but at this moment all of this seems to be the best solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a query with the Criteria API from JPA 2.0, but
I want to query an nhibernate mapped class but the result should be an
There is a LINQ query: int criteria = GetCriteria(); var teams = Team.GetTeams() .Where(team=>
I have this query: criteria = session.CreateCriteria(typeof (Building)) .CreateAlias(Estate, estate) .SetProjection(Projections.ProjectionList() .Add(Property.ForName(Name), BuildingName) .Add(Property.ForName(estate.Name),
I'm able to set variable values for where restrictives: Query criteria = session.createQuery( select
Consider the following criteria query: var x = SomeCriteria.AddOrder(new Order(Name, true)).List(); This will order
I have a criteria query: Session.CreateCriteria<Sell043Report>() .SetProjection(.ProjectionList() .Add(LambdaProjection.GroupProperty<Sell043Report>(r => r.location)) .Add(LambdaProjection.GroupProperty<Sell043Report>(r => r.agent)) .Add(LambdaProjection.GroupProperty<Sell043Report>(r
What is the simplest hibernate criteria query equivalent of SELECT name FROM people WHERE
Can anyone help me to get the JPA criteria query for the JPA query
I am attempting to convert the following HQL query to Criteria. from SubportfolioAudit as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.